summaryrefslogtreecommitdiffstats
path: root/.devcontainer
diff options
context:
space:
mode:
authorRobin Windey <ro.windey@gmail.com>2023-03-27 07:05:27 +0000
committerGitHub <noreply@github.com>2023-03-31 13:53:04 +0000
commita32e8db7031bbb3e183afdf8cabc9b16910dec86 (patch)
treeb1c83168bd14c2ffc86035cc5d98b7b13c63fe45 /.devcontainer
parent79fb336d35953a1bad648e256c5f57eee2809041 (diff)
downloadnextcloud-server-a32e8db7031bbb3e183afdf8cabc9b16910dec86.tar.gz
nextcloud-server-a32e8db7031bbb3e183afdf8cabc9b16910dec86.zip
Minor DevContainer adjustments
* Add gnupg2 to be able to sign commits * Make sure /var/www/html always belongs to www-data * Add Git-History plugin * Introduce dedicated entrypoint script * Store Postgres database data in volume to be persistent * Cleaner check if NC is already installed in setup.sh * Add composer to DevContainer Signed-off-by: GitHub <noreply@github.com>
Diffstat (limited to '.devcontainer')
-rw-r--r--.devcontainer/Dockerfile13
-rw-r--r--.devcontainer/README.md35
-rw-r--r--.devcontainer/devcontainer.json4
-rw-r--r--.devcontainer/docker-compose.yml8
-rwxr-xr-x.devcontainer/entrypoint.sh6
-rwxr-xr-x.devcontainer/setup.sh7
6 files changed, 65 insertions, 8 deletions
diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile
index b674943a587..642ee36d1a1 100644
--- a/.devcontainer/Dockerfile
+++ b/.devcontainer/Dockerfile
@@ -4,7 +4,7 @@ ARG DEBIAN_FRONTEND=noninteractive
# PHP
RUN apt-get update -y && \
- apt install -y apache2 vim software-properties-common sudo nano
+ apt install -y apache2 vim software-properties-common sudo nano gnupg2
RUN apt-get install --no-install-recommends -y \
php8.1 \
@@ -36,6 +36,15 @@ RUN apt-get install --no-install-recommends -y \
nodejs \
npm
+# Composer
+# Download the Composer installer script to a temporary file
+RUN curl -sS https://getcomposer.org/installer -o /tmp/composer-setup.php && \
+ curl -sS https://composer.github.io/installer.sig -o /tmp/composer-setup.sig && \
+ 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); }" && \
+ php /tmp/composer-setup.php --install-dir=/usr/local/bin --filename=composer && \
+ rm /tmp/composer-setup.php /tmp/composer-setup.sig
+
+
RUN echo "xdebug.remote_enable = 1" >> /etc/php/8.1/cli/conf.d/20-xdebug.ini && \
echo "xdebug.remote_autostart = 1" >> /etc/php/8.1/cli/conf.d/20-xdebug.ini
@@ -52,7 +61,7 @@ RUN apt-get -y install \
curl \
gnupg-agent \
software-properties-common && \
- curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add - && \
+ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add - && \
add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) \
diff --git a/.devcontainer/README.md b/.devcontainer/README.md
new file mode 100644
index 00000000000..b1c8ed6d340
--- /dev/null
+++ b/.devcontainer/README.md
@@ -0,0 +1,35 @@
+# Nextcloud DevContainer
+
+## Usage
+
+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*.
+
+Alternatively open the project directly in [GitHub Codespaces](https://github.com/features/codespaces).
+
+That's already it. Everything else will be configured automatically by the Containers startup routine.
+
+## Credentials
+
+On first start the Container installs and configures Nextcloud with the following credentials:
+
+**Nextcloud Admin Login**
+
+Username: `admin` <br>
+Password: `admin`
+
+**Postgres credentials**
+
+Username: `postgres` <br>
+Password: `postgres` <br>
+Database: `postgres`
+
+## Services
+
+The following services will be started:
+
+| Service | Local port | Description |
+|---------|------------|-------------|
+| Nextcloud (served via Apache) | `80` | The main application |
+| Mailhog | `8025` | SMTP email delivery for testing |
+| Adminer | `8080` | Database viewer. Use credentials from above and connect to `localhost:5432` to get access to the NC database |
+
diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json
index 2f197a58fed..709744e3f0d 100644
--- a/.devcontainer/devcontainer.json
+++ b/.devcontainer/devcontainer.json
@@ -3,6 +3,7 @@
"dockerComposeFile": "docker-compose.yml",
"service": "nextclouddev",
"postCreateCommand": ".devcontainer/setup.sh",
+ "postStartCommand": "chown -R www-data:www-data /var/www/html",
"forwardPorts": [
80,
8080,
@@ -14,7 +15,8 @@
"felixfbecker.php-debug",
"felixfbecker.php-intellisense",
"ms-azuretools.vscode-docker",
- "xdebug.php-debug"
+ "xdebug.php-debug",
+ "donjayamanne.githistory"
],
"settings": {
"php.suggest.basic": false
diff --git a/.devcontainer/docker-compose.yml b/.devcontainer/docker-compose.yml
index cb46f3ce800..a30bba74a66 100644
--- a/.devcontainer/docker-compose.yml
+++ b/.devcontainer/docker-compose.yml
@@ -6,7 +6,7 @@ services:
- .:/workspace:cached
- /var/run/docker.sock:/var/run/docker-host.sock
- ..:/var/www/html
- command: /bin/sh -c "chown -R www-data:www-data /var/www/html && service apache2 start && while sleep 1000; do :; done"
+ command: /var/www/html/.devcontainer/entrypoint.sh
ports:
- 80:80
- 8080:8080
@@ -17,6 +17,9 @@ services:
restart: always
environment:
POSTGRES_PASSWORD: postgres
+ PGDATA: /data/postgres
+ volumes:
+ - db:/data/postgres
network_mode: service:nextclouddev
adminer:
@@ -28,3 +31,6 @@ services:
image: mailhog/mailhog
restart: always
network_mode: service:nextclouddev
+
+volumes:
+ db:
diff --git a/.devcontainer/entrypoint.sh b/.devcontainer/entrypoint.sh
new file mode 100755
index 00000000000..a2aecb7ecb7
--- /dev/null
+++ b/.devcontainer/entrypoint.sh
@@ -0,0 +1,6 @@
+#!/bin/bash
+
+# Set proper permissions and start webserver
+chown -R www-data:www-data /var/www/html && service apache2 start
+
+while sleep 1000; do :; done
diff --git a/.devcontainer/setup.sh b/.devcontainer/setup.sh
index e3595123b84..aec20f3b4dc 100755
--- a/.devcontainer/setup.sh
+++ b/.devcontainer/setup.sh
@@ -9,9 +9,10 @@ cp .devcontainer/codespace.config.php config/codespace.config.php
# Set git safe.directory
git config --global --add safe.directory /var/www/html
+git config --global --add safe.directory /var/www/html/3rdparty
# Onetime installation setup
-if [ ! -f "data/.devcontainer-install-complete" ]; then
+if [[ ! $(sudo -u www-data php occ status) =~ installed:[[:space:]]*true ]]; then
echo "Running NC installation"
sudo -u www-data php occ maintenance:install \
--verbose \
@@ -22,9 +23,7 @@ if [ ! -f "data/.devcontainer-install-complete" ]; then
--database-user=postgres \
--database-pass=postgres \
--admin-user admin \
- --admin-pass admin && \
- touch "data/.devcontainer-install-complete"
+ --admin-pass admin
fi
-# Clear caches and stuff ...
service apache2 restart