docs: add healthcheck to docker compose examples
continuous-integration/drone/push Build was killed Details

This commit is contained in:
kolaente 2024-02-11 18:31:41 +01:00
parent 3129051a9c
commit 001268a33e
Signed by: konrad
GPG Key ID: F40E70337AB24C9B
2 changed files with 24 additions and 5 deletions

View File

@ -47,7 +47,8 @@ services:
volumes: volumes:
- ./files:/app/vikunja/files - ./files:/app/vikunja/files
depends_on: depends_on:
- db db:
condition: service_healthy
restart: unless-stopped restart: unless-stopped
db: db:
image: mariadb:10 image: mariadb:10
@ -60,6 +61,9 @@ services:
volumes: volumes:
- ./db:/var/lib/mysql - ./db:/var/lib/mysql
restart: unless-stopped restart: unless-stopped
healthcheck:
test: ["CMD", "mysqladmin", "ping", "--silent"]
interval: 2s
``` ```
This defines two services, each with their own container: This defines two services, each with their own container:

View File

@ -34,13 +34,16 @@ To use postgres as a database backend, change the `db` section of the examples t
```yaml ```yaml
db: db:
image: postgres:13 image: postgres:16
environment: environment:
POSTGRES_PASSWORD: secret POSTGRES_PASSWORD: secret
POSTGRES_USER: vikunja POSTGRES_USER: vikunja
volumes: volumes:
- ./db:/var/lib/postgresql/data - ./db:/var/lib/postgresql/data
restart: unless-stopped restart: unless-stopped
healthcheck:
test: ["CMD-SHELL", "pg_isready -d $${POSTGRES_DB} -U $${POSTGRES_USER}"]
interval: 2s
``` ```
You'll also need to change the `VIKUNJA_DATABASE_TYPE` to `postgres` on the api container declaration. You'll also need to change the `VIKUNJA_DATABASE_TYPE` to `postgres` on the api container declaration.
@ -111,7 +114,8 @@ services:
volumes: volumes:
- ./files:/app/vikunja/files - ./files:/app/vikunja/files
depends_on: depends_on:
- db db:
condition: service_healthy
restart: unless-stopped restart: unless-stopped
db: db:
image: mariadb:10 image: mariadb:10
@ -124,6 +128,9 @@ services:
volumes: volumes:
- ./db:/var/lib/mysql - ./db:/var/lib/mysql
restart: unless-stopped restart: unless-stopped
healthcheck:
test: ["CMD", "mysqladmin", "ping", "--silent"]
interval: 2s
``` ```
## Example with Traefik 2 ## Example with Traefik 2
@ -156,7 +163,8 @@ services:
- web - web
- default - default
depends_on: depends_on:
- db db:
condition: service_healthy
restart: unless-stopped restart: unless-stopped
labels: labels:
- "traefik.enable=true" - "traefik.enable=true"
@ -175,6 +183,9 @@ services:
volumes: volumes:
- ./db:/var/lib/mysql - ./db:/var/lib/mysql
restart: unless-stopped restart: unless-stopped
healthcheck:
test: ["CMD", "mysqladmin", "ping", "--silent"]
interval: 2s
networks: networks:
web: web:
@ -215,7 +226,8 @@ services:
volumes: volumes:
- ./files:/app/vikunja/files - ./files:/app/vikunja/files
depends_on: depends_on:
- db db:
condition: service_healthy
restart: unless-stopped restart: unless-stopped
db: db:
image: mariadb:10 image: mariadb:10
@ -228,6 +240,9 @@ services:
volumes: volumes:
- ./db:/var/lib/mysql - ./db:/var/lib/mysql
restart: unless-stopped restart: unless-stopped
healthcheck:
test: ["CMD", "mysqladmin", "ping", "--silent"]
interval: 2s
caddy: caddy:
image: caddy image: caddy
restart: unless-stopped restart: unless-stopped