Fixes the setup issue almost all Raspberry Pi users have and probably some others with slow or low spec systems. The web_recipes container waits for db_recipes to be healthy. db_recipes is healthy, as soon as postgres is completely ready. Note: ps_isready doesn't work here for some reason. Tested multiple times with a Raspberry Pi 4.
46 lines
960 B
YAML
46 lines
960 B
YAML
version: "3"
|
|
services:
|
|
db_recipes:
|
|
restart: always
|
|
image: postgres:11-alpine
|
|
volumes:
|
|
- ./postgresql:/var/lib/postgresql/data
|
|
env_file:
|
|
- ./.env
|
|
healthcheck:
|
|
test: ["CMD-SHELL", "psql -U $$POSTGRES_USER -d $$POSTGRES_DB --list || exit 1"]
|
|
interval: 5s
|
|
timeout: 2s
|
|
retries: 5
|
|
|
|
web_recipes:
|
|
image: vabene1111/recipes
|
|
restart: always
|
|
env_file:
|
|
- ./.env
|
|
volumes:
|
|
- staticfiles:/opt/recipes/staticfiles
|
|
- nginx_config:/opt/recipes/nginx/conf.d
|
|
- ./mediafiles:/opt/recipes/mediafiles
|
|
depends_on:
|
|
db_recipes:
|
|
condition: service_healthy
|
|
|
|
nginx_recipes:
|
|
image: nginx:mainline-alpine
|
|
restart: always
|
|
ports:
|
|
- 80:80
|
|
env_file:
|
|
- ./.env
|
|
depends_on:
|
|
- web_recipes
|
|
volumes:
|
|
- nginx_config:/etc/nginx/conf.d:ro
|
|
- staticfiles:/static
|
|
- ./mediafiles:/media
|
|
|
|
volumes:
|
|
nginx_config:
|
|
staticfiles:
|