From ce701c22309b4f494fd18f20cdb223779ee2a004 Mon Sep 17 00:00:00 2001 From: nouryxd <66651385+nouryxd@users.noreply.github.com> Date: Fri, 19 Jul 2024 22:18:35 +0200 Subject: [PATCH] wait for postgres container to start. provide env variables through .env file --- env.example | 8 +++----- example.docker-compose | 16 ++++++++++------ 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/env.example b/env.example index cac828b..8548a28 100644 --- a/env.example +++ b/env.example @@ -10,11 +10,9 @@ TWITCH_CLIENT_SECRET=asd EVENTSUB_SECRET=asd DSN=postgres://nourybot:coolpassword@postgres:5432/nourybot?sslmode=disable -DB_HOST=postgres -DB_PORT=5432 -DB_USER=nourybot -DB_PASSWORD=coolpassword -DB_NAME=nourybot +POSTGRES_DB=nourybot +POSTGRES_USER=nourybot +POSTGRES_PASSWORD=coolpassword OWM_KEY=asd WOLFRAMALPHA_APP_ID=asd diff --git a/example.docker-compose b/example.docker-compose index 7870ae9..8e3122d 100644 --- a/example.docker-compose +++ b/example.docker-compose @@ -6,19 +6,23 @@ services: restart: unless-stopped env_file: .env depends_on: - - postgres + postgres: + condition: service_healthy volumes: - - "/tmp/CHANGE_ME/uploads:/public/uploads" + - "/tmp/CHANGEME/uploads:/public/uploads" ports: - "127.0.0.1:8080:8080" postgres: image: postgres restart: unless-stopped - environment: - POSTGRES_DB: nourybot - POSTGRES_USER: nourybot - POSTGRES_PASSWORD: coolpassword + env_file: .env volumes: - nourybotdb:/var/lib/postgresql/data + healthcheck: + test: ["CMD-SHELL", "pg_isready -U $$POSTGRES_USER -d $$POSTGRES_DB"] + interval: 5s + timeout: 5s + retries: 5 + start_period: 20s volumes: nourybotdb: