From 4193d7ac4b17166d110f2cd9004e79e6242e8a44 Mon Sep 17 00:00:00 2001 From: Thumbscrew Date: Mon, 31 Jan 2022 21:30:08 +0000 Subject: [PATCH] replace mariadb with postgresql load postgres and nextcloud db config from secrets to auto-configure --- .env.example | 4 ++-- .gitignore | 5 +++- docker-compose.yaml | 48 +++++++++++++++++++++++++-------------- secrets/postgres_db.txt | 1 + secrets/postgres_user.txt | 1 + 5 files changed, 39 insertions(+), 20 deletions(-) create mode 100644 secrets/postgres_db.txt create mode 100644 secrets/postgres_user.txt diff --git a/.env.example b/.env.example index 5944644..a46409b 100644 --- a/.env.example +++ b/.env.example @@ -4,8 +4,8 @@ VOLUME_PATH=/data/nextcloud # nextcloud NEXTCLOUD_TAG=23-apache -# mariadb -MARIADB_TAG=10 +# postgres +POSTGRES_TAG=14 # nginx NGINX_HOST=localhost # REPLACE diff --git a/.gitignore b/.gitignore index 26e5337..f285158 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,5 @@ .env -mariadb_password.txt \ No newline at end of file + +# Secrets +secrets/postgres_password.txt +secrets/nextcloud* \ No newline at end of file diff --git a/docker-compose.yaml b/docker-compose.yaml index a0a97bd..38dd634 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -1,21 +1,29 @@ secrets: - mariadb_password: - file: ./mariadb_password.txt + postgres_db: + file: ./secrets/postgres_db.txt + postgres_user: + file: ./secrets/postgres_user.txt + postgres_password: + file: ./secrets/postgres_password.txt + nextcloud_admin_user: + file: ./secrets/nextcloud_admin_user.txt + nextcloud_admin_password: + file: ./secrets/nextcloud_admin_password.txt services: db: - image: mariadb:${MARIADB_TAG} + image: postgres:${POSTGRES_TAG} restart: unless-stopped - command: --transaction-isolation=READ-COMMITTED --binlog-format=ROW --innodb-file-per-table=1 --skip-innodb-read-only-compressed - secrets: - - mariadb_password volumes: - - ${VOLUME_PATH}/var/lib/mysql:/var/lib/mysql + - ${VOLUME_PATH}/var/lib/postgresql/data:/var/lib/postgresql/data:rw + secrets: + - postgres_db + - postgres_user + - postgres_password environment: - MARIADB_RANDOM_ROOT_PASSWORD: "yes" - MARIADB_PASSWORD_FILE: /run/secrets/mariadb_password - MARIADB_DATABASE: nextcloud - MARIADB_USER: nextcloud + POSTGRES_DB_FILE: /run/secrets/postgres_db + POSTGRES_USER_FILE: /run/secrets/postgres_user + POSTGRES_PASSWORD_FILE: /run/secrets/postgres_password redis: image: redis:alpine @@ -28,14 +36,20 @@ services: NEXTCLOUD_TAG: ${NEXTCLOUD_TAG} restart: unless-stopped volumes: - - ${VOLUME_PATH}/var/www/html:/var/www/html + - ${VOLUME_PATH}/var/www/html:/var/www/html:rw secrets: - - mariadb_password + - postgres_db + - postgres_user + - postgres_password + - nextcloud_admin_user + - nextcloud_admin_password environment: - MYSQL_PASSWORD_FILE: /run/secrets/mariadb_password - MYSQL_DATABASE: nextcloud - MYSQL_USER: nextcloud - MYSQL_HOST: db + POSTGRES_PASSWORD_FILE: /run/secrets/postgres_password + POSTGRES_DB_FILE: /run/secrets/postgres_db + POSTGRES_USER_FILE: /run/secrets/postgres_user + POSTGRES_HOST: db + NEXTCLOUD_ADMIN_PASSWORD_FILE: /run/secrets/nextcloud_admin_password + NEXTCLOUD_ADMIN_USER_FILE: /run/secrets/nextcloud_admin_user REDIS_HOST: redis NEXTCLOUD_TRUSTED_DOMAINS: ${NGINX_HOST} OVERWRITEPROTOCOL: https diff --git a/secrets/postgres_db.txt b/secrets/postgres_db.txt new file mode 100644 index 0000000..4530cbc --- /dev/null +++ b/secrets/postgres_db.txt @@ -0,0 +1 @@ +nextcloud \ No newline at end of file diff --git a/secrets/postgres_user.txt b/secrets/postgres_user.txt new file mode 100644 index 0000000..4530cbc --- /dev/null +++ b/secrets/postgres_user.txt @@ -0,0 +1 @@ +nextcloud \ No newline at end of file