diff --git a/.env.sample b/.env.sample index ff62576..42ea31e 100644 --- a/.env.sample +++ b/.env.sample @@ -5,6 +5,10 @@ DOMAIN=nextcloud.example.com #EXTRA_DOMAINS=', `www.nextcloud.example.com`' LETS_ENCRYPT_ENV=production +COMPOSE_FILE="compose.yml" +COMPOSE_FILE="$COMPOSE_FILE:compose.mariadb.yml" +#COMPOSE_FILE="$COMPOSE_FILE:compose.postgres.yml" + ADMIN_USER=admin SECRET_DB_ROOT_PASSWORD_VERSION=v1 diff --git a/compose.mariadb.yml b/compose.mariadb.yml new file mode 100644 index 0000000..956e424 --- /dev/null +++ b/compose.mariadb.yml @@ -0,0 +1,40 @@ +version: "3.8" + +services: + app: + environment: + - MYSQL_HOST=db + - MYSQL_DATABASE=nextcloud + - MYSQL_USER=nextcloud + - MYSQL_PASSWORD_FILE=/run/secrets/db_password + + db: + image: "mariadb:10.5" + environment: + - MYSQL_DATABASE=nextcloud + - MYSQL_USER=nextcloud + - MYSQL_PASSWORD_FILE=/run/secrets/db_password + - MYSQL_ROOT_PASSWORD_FILE=/run/secrets/db_root_password + configs: + - source: my_tune + target: /etc/mysql/conf.d/my-tune.cnf + secrets: + - db_root_password + - db_password + volumes: + - "mariadb:/var/lib/mysql" + networks: + - internal + deploy: + labels: + backupbot.backup: "true" + backupbot.backup.pre-hook: 'mkdir -p /tmp/backup/ && mysqldump --single-transaction -u root -p"$$(cat /run/secrets/db_root_password)" nextcloud > /tmp/backup/backup.sql' + backupbot.backup.post-hook: "rm -rf /tmp/backup" + backupbot.backup.path: "/tmp/backup/" +configs: + my_tune: + name: ${STACK_NAME}_my_cnf_${MY_CNF_VERSION} + file: my-tune.cnf + +volumes: + mariadb: diff --git a/compose.postgres.yml b/compose.postgres.yml new file mode 100644 index 0000000..02fd6f2 --- /dev/null +++ b/compose.postgres.yml @@ -0,0 +1,38 @@ +version: '3.8' + +services: + app: + entrypoint: "sh -c 'sleep 10 && /entrypoint.sh php-fpm'" # tries to mitigate this error with postgres https://github.com/nextcloud/docker/issues/1204 + environment: + - POSTGRES_HOST=db + - POSTGRES_DB=nextcloud + - POSTGRES_USER=nextcloud + - POSTGRES_PASSWORD_FILE=/run/secrets/db_password + - NEXTCLOUD_UPDATE=1 + + db: + image: "postgres:12" + volumes: + - "postgres:/var/lib/postgresql/data" + networks: + - internal + environment: + POSTGRES_USER: nextcloud + POSTGRES_PASSWORD_FILE: /run/secrets/db_password + POSTGRES_DB: nextcloud + secrets: + - db_password + healthcheck: + test: ["CMD-SHELL", "pg_isready"] + interval: 10s + timeout: 5s + retries: 5 + deploy: + labels: + backupbot.backup: "true" + backupbot.backup.pre-hook: "mkdir -p /tmp/backup/ && PGPASSWORD=$$(cat $${POSTGRES_PASSWORD_FILE}) pg_dump -U $${POSTGRES_USER} $${POSTGRES_DB} > /tmp/backup/backup.sql" + backupbot.backup.post-hook: "rm -rf /tmp/backup" + backupbot.backup.path: "/tmp/backup/" + +volumes: + postgres: diff --git a/compose.yml b/compose.yml index 4333544..2f8676d 100644 --- a/compose.yml +++ b/compose.yml @@ -33,7 +33,7 @@ services: - "traefik.http.middlewares.${STACK_NAME}-redirect.headers.SSLHost=${DOMAIN}" app: - image: nextcloud:23.0.1-fpm + image: nextcloud:23.0.3-fpm depends_on: - db configs: @@ -45,10 +45,6 @@ services: environment: - DOMAIN - STACK_NAME - - MYSQL_HOST=db - - MYSQL_DATABASE=nextcloud - - MYSQL_USER=nextcloud - - MYSQL_PASSWORD_FILE=/run/secrets/db_password - NEXTCLOUD_ADMIN_USER=${ADMIN_USER} - NEXTCLOUD_ADMIN_PASSWORD_FILE=/run/secrets/admin_password - NEXTCLOUD_TRUSTED_DOMAINS=${DOMAIN} @@ -73,28 +69,13 @@ services: failure_action: rollback order: start-first labels: - - "coop-cloud.${STACK_NAME}.version=1.0.0+23.0.1-fpm" + - "coop-cloud.${STACK_NAME}.version=2.0.0+23.0.3-fpm" + - "backupbot.backup=true" + - "backupbot.backup.path=/var/www/html/config/,/var/www/html/data/,/var/www/html/custom_apps/" - db: - image: "mariadb:10.5" - environment: - - MYSQL_DATABASE=nextcloud - - MYSQL_USER=nextcloud - - MYSQL_PASSWORD_FILE=/run/secrets/db_password - - MYSQL_ROOT_PASSWORD_FILE=/run/secrets/db_root_password - configs: - - source: my_tune - target: /etc/mysql/conf.d/my-tune.cnf - secrets: - - db_root_password - - db_password - volumes: - - "mariadb:/var/lib/mysql" - networks: - - internal cron: - image: nextcloud:23.0.1-fpm + image: nextcloud:23.0.3-fpm volumes: - nextcloud:/var/www/html/ - nextapps:/var/www/html/custom_apps:cached @@ -128,7 +109,6 @@ volumes: nextapps: nextdata: nextconfig: - mariadb: redis: configs: @@ -139,9 +119,6 @@ configs: fpm_tune: name: ${STACK_NAME}_fpm_tune_${FPM_TUNE_VERSION} file: fpm-tune.ini - my_tune: - name: ${STACK_NAME}_my_cnf_${MY_CNF_VERSION} - file: my-tune.cnf networks: proxy: diff --git a/releases/2.0.0+23.0.3-fpm b/releases/2.0.0+23.0.3-fpm new file mode 100644 index 0000000..3dead5b --- /dev/null +++ b/releases/2.0.0+23.0.3-fpm @@ -0,0 +1,6 @@ +2.0.0 introduces a minor nextcloud update to 23.0.3 and moves the database service to a seperate override.yml file to support different database types (mariadb / postgres). This might break your installation. Please add the following snippet to your config .env to ensure the right db is used: + +``` +COMPOSE_FILE="compose.yml" +COMPOSE_FILE="$COMPOSE_FILE:compose.mariadb.yml" +```