railslove/ebicsbox

docker-compose.with_db.yml healthchecks fail out of the box

Opened this issue · 0 comments

The postgres database in docker-compose.with_db.yml fails to startup by default.

The error for that is that the POSTGRES_USER is not available for the healtcheck via pg_isready, because compose does not lookup the environment variables of a service. Unless it is specifically declared in an .env file it fails to run. And since everything depends on the postgres db, the whole stack fails to launch.

db:
image: postgres
restart: always
# set shared memory limit when using docker-compose
shm_size: 128mb
environment:
- POSTGRES_DB=ebicsbox
- POSTGRES_USER=ebicsbox
- POSTGRES_PASSWORD=password
networks:
- ebicsbox_network
healthcheck:
test: ["CMD-SHELL", "pg_isready -U $POSTGRES_USER"]
interval: 10s
timeout: 5s
retries: 5
db_test:
image: postgres
restart: always
# set shared memory limit when using docker-compose
shm_size: 128mb
environment:
- POSTGRES_DB=ebicsbox_test
- POSTGRES_USER=ebicsbox_test
- POSTGRES_PASSWORD=password
networks:
- ebicsbox_network
healthcheck:
test: ["CMD-SHELL", "pg_isready -U $POSTGRES_USER"]
interval: 10s
timeout: 5s
retries: 5

Potential solution: move the default environment to .env.example and mention to copy the file to .env in the readme.