diff --git a/fastapi-postgres/docker-compose.yml b/fastapi-postgres/docker-compose.yml index fd49830..90df13a 100644 --- a/fastapi-postgres/docker-compose.yml +++ b/fastapi-postgres/docker-compose.yml @@ -1,6 +1,6 @@ version: '3.9' -services: +services: postgres: image: postgres:latest container_name: postgres @@ -9,26 +9,37 @@ services: POSTGRES_USER: postgres POSTGRES_PASSWORD: postgres ports: - - "5432:5432" # Map the PostgreSQL port to the host machine + - "5432:5432" volumes: + - postgres-data:/var/lib/postgresql/data - ./sql/init.sql:/docker-entrypoint-initdb.d/init.sql networks: - keploy-network + healthcheck: + test: ["CMD-SHELL", "pg_isready -U postgres"] + interval: 10s + timeout: 5s + retries: 5 app: container_name: fastapi-app - image: fastapi + image: keploy/fastapi-app:latest build: context: . dockerfile: Dockerfile restart: unless-stopped ports: - - 8000:8000 + - "8000:8000" depends_on: - - postgres + postgres: + condition: service_healthy networks: - keploy-network +volumes: + postgres-data: + networks: keploy-network: - external: true + name: keploy-network + driver: bridge