Skip to content

Commit b549989

Browse files
authored
Merge f721e70 into c5cc4ca
2 parents c5cc4ca + f721e70 commit b549989

File tree

9,493 files changed

+480480
-291766
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

9,493 files changed

+480480
-291766
lines changed

.codecov.yml

Lines changed: 0 additions & 15 deletions
This file was deleted.

.devcontainer/Dockerfile

Lines changed: 67 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,86 @@
1-
FROM ubuntu:focal
1+
FROM ubuntu:jammy
22

33
ARG DEBIAN_FRONTEND=noninteractive
44

55
# PHP
6-
RUN apt-get update -y
6+
RUN apt-get update -y && \
7+
apt install -y apache2 vim software-properties-common sudo nano gnupg2
8+
79
RUN apt-get install --no-install-recommends -y \
8-
php7.4 \
9-
php7.4-gd \
10-
php7.4-zip \
11-
php7.4-curl \
12-
php7.4-xml \
13-
php7.4-mbstring \
14-
php7.4-sqlite \
15-
php7.4-xdebug \
16-
php7.4-pgsql \
17-
php7.4-intl \
18-
php7.4-imagick \
19-
php7.4-gmp \
20-
php7.4-apcu \
21-
php7.4-bcmath \
10+
php8.1 \
11+
php8.1-common \
12+
php8.1-gd \
13+
php8.1-zip \
14+
php8.1-curl \
15+
php8.1-xml \
16+
php8.1-xmlrpc \
17+
php8.1-mbstring \
18+
php8.1-sqlite \
19+
php8.1-xdebug \
20+
php8.1-pgsql \
21+
php8.1-intl \
22+
php8.1-imagick \
23+
php8.1-gmp \
24+
php8.1-apcu \
25+
php8.1-bcmath \
26+
php8.1-redis \
27+
php8.1-soap \
28+
php8.1-imap \
29+
php8.1-opcache \
30+
php8.1-cli \
31+
php8.1-dev \
2232
libmagickcore-6.q16-3-extra \
2333
curl \
24-
vim \
2534
lsof \
2635
make \
27-
nodejs \
28-
npm
36+
unzip
37+
38+
# Composer
39+
RUN curl -sS https://getcomposer.org/installer -o /tmp/composer-setup.php && \
40+
curl -sS https://composer.github.io/installer.sig -o /tmp/composer-setup.sig && \
41+
php -r "if (hash_file('sha384', '/tmp/composer-setup.php') !== trim(file_get_contents('/tmp/composer-setup.sig'))) { echo 'Composer installation failed, invalid hash'; exit(1); }" && \
42+
php /tmp/composer-setup.php --install-dir=/usr/local/bin --filename=composer && \
43+
rm /tmp/composer-setup.php /tmp/composer-setup.sig
2944

30-
RUN echo "xdebug.remote_enable = 1" >> /etc/php/7.4/cli/conf.d/20-xdebug.ini
31-
RUN echo "xdebug.remote_autostart = 1" >> /etc/php/7.4/cli/conf.d/20-xdebug.ini
45+
RUN echo "xdebug.remote_enable = 1" >> /etc/php/8.1/cli/conf.d/20-xdebug.ini && \
46+
echo "xdebug.remote_autostart = 1" >> /etc/php/8.1/cli/conf.d/20-xdebug.ini && \
47+
echo "apc.enable_cli=1" >> /etc/php/8.1/cli/conf.d/20-apcu.ini
48+
49+
# Autostart XDebug for apache
50+
RUN { \
51+
echo "xdebug.mode=debug"; \
52+
echo "xdebug.start_with_request=yes"; \
53+
} >> /etc/php/8.1/apache2/conf.d/20-xdebug.ini
3254

3355
# Docker
3456
RUN apt-get -y install \
3557
apt-transport-https \
3658
ca-certificates \
3759
curl \
3860
gnupg-agent \
39-
software-properties-common
40-
RUN curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add -
41-
RUN add-apt-repository \
61+
software-properties-common && \
62+
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add - && \
63+
add-apt-repository \
4264
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \
4365
$(lsb_release -cs) \
44-
stable"
45-
RUN apt-get update -y
46-
RUN apt-get install -y docker-ce docker-ce-cli containerd.io
47-
RUN ln -s /var/run/docker-host.sock /var/run/docker.sock
66+
stable" && \
67+
apt-get update -y && \
68+
apt-get install -y docker-ce docker-ce-cli containerd.io && \
69+
ln -s /var/run/docker-host.sock /var/run/docker.sock
70+
71+
# Dedicated DevContainer user runs Apache
72+
ENV APACHE_RUN_USER=devcontainer
73+
ENV APACHE_RUN_GROUP=devcontainer
74+
RUN useradd -ms /bin/bash ${APACHE_RUN_USER} && \
75+
adduser ${APACHE_RUN_USER} sudo && \
76+
echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers && \
77+
sed -ri "s/^export APACHE_RUN_USER=.*$/export APACHE_RUN_USER=${APACHE_RUN_USER}/" "/etc/apache2/envvars" && \
78+
sed -ri "s/^export APACHE_RUN_GROUP=.*$/export APACHE_RUN_GROUP=${APACHE_RUN_GROUP}/" "/etc/apache2/envvars"
79+
80+
USER devcontainer
81+
82+
# NVM
83+
RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash
84+
RUN bash --login -i -c 'source /home/devcontainer/.bashrc && nvm install 16'
85+
86+
WORKDIR /var/www/html

.devcontainer/README.md

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
# Nextcloud DevContainer
2+
3+
## Usage
4+
5+
Make sure you have the [VSCode DevContainer](https://code.visualstudio.com/docs/devcontainers/containers) extensions installed. If you open the project, VSCode will ask you if you want to open it inside of the DevContainer. If that's not the case, use <kbd>F1</kbd>&rarr;*Dev Containers: Open Folder in Container*.
6+
7+
Alternatively open the project directly in [GitHub Codespaces](https://github.com/features/codespaces).
8+
9+
That's already it. Everything else will be configured automatically by the Containers startup routine.
10+
11+
## Credentials
12+
13+
On first start the Container installs and configures Nextcloud with the following credentials:
14+
15+
**Nextcloud Admin Login**
16+
17+
Username: `admin` <br>
18+
Password: `admin`
19+
20+
**Postgres credentials**
21+
22+
Username: `postgres` <br>
23+
Password: `postgres` <br>
24+
Database: `postgres`
25+
26+
## Services
27+
28+
The following services will be started:
29+
30+
| Service | Local port | Description |
31+
|---------|------------|-------------|
32+
| Nextcloud (served via Apache) | `80` | The main application |
33+
| Mailhog | `8025` | SMTP email delivery for testing |
34+
| Adminer | `8080` | Database viewer. Use credentials from above and connect to `localhost` to get access to the NC database |
35+
36+
## Permissions
37+
38+
The container runs with the user `devcontainer` who is also running the Apache2 process. All mounted source files have
39+
proper permissions so that this user can access everything which is inside the current workspace. If you need to
40+
get root permissions for whatever reason, use `sudo su` or `sudo <command>` (for example `sudo service apache2 restart`).
41+
Everything else (like building the application, adjusting files, ...) should be done as `devcontainer` user.
42+
43+
## NodeJs and NVM
44+
45+
The container comes with [`nvm`](https://github.com/nvm-sh/nvm) and Node 16 installed. This should be sufficient to
46+
build Nextcloud Core sources via `make`. If you need a different Node Version (for example for
47+
app development), you can easily switch between different versions by running:
48+
49+
```bash
50+
# Install and use Node 14
51+
nvm install 14
52+
nvm use 14
53+
54+
# Check version
55+
node -v
56+
57+
# Switch back to Node 16
58+
nvm use 16
59+
60+
# Check version
61+
node -v
62+
```
63+
64+
Note that `nvm` is only installed for the user `devcontainer` and won't work out of the box for
65+
any other user.
66+
67+
## Debugging
68+
69+
The Apache webserver is already configured to automatically try to connect to a debugger process
70+
listening on port `9003`. To start the VSCode debugger process, use the delivered debug profile `Listen for XDebug`.
71+
After you started the VSCode debugger, just navigate to the appropriate Nextcloud URL to get your
72+
debug hits.

.devcontainer/codespace.config.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<?php
22

3-
$cloudEnvironmentId = getenv('CLOUDENV_ENVIRONMENT_ID');
3+
$codespaceName = getenv('CODESPACE_NAME');
4+
$codespaceDomain = getenv('GITHUB_CODESPACES_PORT_FORWARDING_DOMAIN');
45

56
$CONFIG = [
67
'mail_from_address' => 'no-reply',
@@ -12,7 +13,10 @@
1213
'memcache.local' => '\OC\Memcache\APCu',
1314
];
1415

15-
if($cloudEnvironmentId !== true) {
16-
$CONFIG['overwritehost'] = $cloudEnvironmentId . '-80.apps.codespaces.githubusercontent.com';
16+
if(is_string($codespaceName) && !empty($codespaceName) && is_string($codespaceDomain) && !empty($codespaceDomain)) {
17+
$host = $codespaceName . '-80.' . $codespaceDomain;
18+
$CONFIG['overwritehost'] = $host;
19+
$CONFIG['overwrite.cli.url'] = 'https://' . $host;
1720
$CONFIG['overwriteprotocol'] = 'https';
21+
$CONFIG['trusted_domains'] = [ $host ];
1822
}

.devcontainer/devcontainer.json

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,26 @@
33
"dockerComposeFile": "docker-compose.yml",
44
"service": "nextclouddev",
55
"postCreateCommand": ".devcontainer/setup.sh",
6+
"postStartCommand": ".devcontainer/postStart.sh",
67
"forwardPorts": [
78
80,
89
8080,
910
8025
1011
],
11-
"runArgs": [
12-
"--privileged"
13-
],
14-
"extensions": [
15-
"felixfbecker.php-debug",
16-
"felixfbecker.php-intellisense",
17-
"ms-azuretools.vscode-docker"
18-
],
19-
"settings": {
20-
"php.suggest.basic": false,
21-
}
12+
"customizations": {
13+
"vscode": {
14+
"extensions": [
15+
"felixfbecker.php-debug",
16+
"felixfbecker.php-intellisense",
17+
"ms-azuretools.vscode-docker",
18+
"xdebug.php-debug",
19+
"donjayamanne.githistory"
20+
],
21+
"settings": {
22+
"php.suggest.basic": false
23+
}
24+
}
25+
},
26+
"workspaceFolder": "/var/www/html",
27+
"remoteUser": "devcontainer"
2228
}

.devcontainer/docker-compose.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ services:
55
volumes:
66
- .:/workspace:cached
77
- /var/run/docker.sock:/var/run/docker-host.sock
8-
command: /bin/sh -c "while sleep 1000; do :; done"
8+
- ..:/var/www/html
9+
command: /var/www/html/.devcontainer/entrypoint.sh
910
ports:
1011
- 80:80
1112
- 8080:8080
@@ -16,6 +17,9 @@ services:
1617
restart: always
1718
environment:
1819
POSTGRES_PASSWORD: postgres
20+
PGDATA: /data/postgres
21+
volumes:
22+
- db:/data/postgres
1923
network_mode: service:nextclouddev
2024

2125
adminer:
@@ -27,3 +31,6 @@ services:
2731
image: mailhog/mailhog
2832
restart: always
2933
network_mode: service:nextclouddev
34+
35+
volumes:
36+
db:

.devcontainer/entrypoint.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/bin/bash
2+
3+
sudo service apache2 start
4+
5+
while sleep 1000; do :; done

.devcontainer/launch.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
// Use IntelliSense to learn about possible attributes.
3+
// Hover to view descriptions of existing attributes.
4+
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5+
"version": "0.2.0",
6+
"configurations": [
7+
{
8+
"name": "Listen for Xdebug",
9+
"type": "php",
10+
"request": "launch",
11+
"port": 9003
12+
}
13+
]
14+
}

.devcontainer/postStart.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/bin/bash
2+
3+
# Set git safe.directory
4+
git config --global --add safe.directory /var/www/html
5+
git config --global --add safe.directory /var/www/html/3rdparty

.devcontainer/setup.sh

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,28 @@
22
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )/../" >/dev/null 2>&1 && pwd )"
33

44
cd $DIR/
5+
56
git submodule update --init
67

78
# Codespace config
89
cp .devcontainer/codespace.config.php config/codespace.config.php
10+
11+
# VSCode debugger profile
12+
mkdir -p .vscode && cp .devcontainer/launch.json .vscode/launch.json
13+
14+
# Onetime installation setup
15+
if [[ ! $(sudo -u ${APACHE_RUN_USER} php occ status) =~ installed:[[:space:]]*true ]]; then
16+
echo "Running NC installation"
17+
sudo -u ${APACHE_RUN_USER} php occ maintenance:install \
18+
--verbose \
19+
--database=pgsql \
20+
--database-name=postgres \
21+
--database-host=127.0.0.1 \
22+
--database-port=5432 \
23+
--database-user=postgres \
24+
--database-pass=postgres \
25+
--admin-user admin \
26+
--admin-pass admin
27+
fi
28+
29+
sudo service apache2 restart

0 commit comments

Comments
 (0)