feat: Separate compose files (#1)

* separate postgres db into separate override compose file

* add instructions for docker compose up with or without postgres
This commit is contained in:
James 2022-09-27 20:22:37 +01:00 committed by GitHub
parent 2df8d080b3
commit 4275b50e2d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 31 additions and 20 deletions

View File

@ -11,3 +11,4 @@ NEXTCLOUD_MEM_LIMIT=4g
# postgres
POSTGRES_TAG=14
POSTGRES_HOST=db

View File

@ -1,5 +1,5 @@
# Nextcloud (Docker Compose)
Build a Nextcloud instance in Docker Compose complete with PostgreSQL and Redis
Build a Nextcloud instance in Docker Compose complete with Redis and optional PostgreSQL
## Prerequisites
@ -36,7 +36,11 @@ cp .env.example .env
7. Bring up the containers!
```bash
# No PostgreSQL (if you have your own PostgreSQL DB)
sudo docker-compose -p nextcloud up --build -d
# With Dockerized PostgreSQL
sudo docker-compose -f docker-compose.yaml -f docker-compose.db.yaml -p nextcloud up --build -d
```
8. (Optional) To enable some file previews copy [previews.config.php](nextcloud/previews.config.php) into your Nextcloud's `config` directory (replace `$volume` with the path you have set in the `VOLUME_PATH` environment variable):

24
docker-compose.db.yaml Normal file
View File

@ -0,0 +1,24 @@
services:
db:
image: postgres:${POSTGRES_TAG}
restart: unless-stopped
volumes:
- ${VOLUME_PATH}/var/lib/postgresql/data:/var/lib/postgresql/data:rw
secrets:
- postgres_db
- postgres_user
- postgres_password
networks:
- backend
environment:
POSTGRES_DB_FILE: /run/secrets/postgres_db
POSTGRES_USER_FILE: /run/secrets/postgres_user
POSTGRES_PASSWORD_FILE: /run/secrets/postgres_password
nextcloud:
environment:
POSTGRES_HOST: db
depends_on:
- db
cron:
depends_on:
- db

View File

@ -17,22 +17,6 @@ networks:
backend:
services:
db:
image: postgres:${POSTGRES_TAG}
restart: unless-stopped
volumes:
- ${VOLUME_PATH}/var/lib/postgresql/data:/var/lib/postgresql/data:rw
secrets:
- postgres_db
- postgres_user
- postgres_password
networks:
- backend
environment:
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
restart: unless-stopped
@ -62,14 +46,13 @@ services:
POSTGRES_PASSWORD_FILE: /run/secrets/postgres_password
POSTGRES_DB_FILE: /run/secrets/postgres_db
POSTGRES_USER_FILE: /run/secrets/postgres_user
POSTGRES_HOST: db
POSTGRES_HOST: ${POSTGRES_HOST}
NEXTCLOUD_ADMIN_PASSWORD_FILE: /run/secrets/nextcloud_admin_password
NEXTCLOUD_ADMIN_USER_FILE: /run/secrets/nextcloud_admin_user
REDIS_HOST: redis
NEXTCLOUD_TRUSTED_DOMAINS: ${NEXTCLOUD_DOMAIN}
OVERWRITEPROTOCOL: https
depends_on:
- db
- redis
cron:
@ -81,5 +64,4 @@ services:
- backend
entrypoint: /cron.sh
depends_on:
- db
- redis