services:
  postgres-pgdog:
    image: ${PGDOG_IMAGE}
    restart: unless-stopped
    # Uncomment 'ports' settings below to enable external access
    # ports:
    #   - "6432:6432"
    volumes:
      - ../files/pgdog.toml:/pgdog/pgdog.toml
      - ../files/users.toml:/pgdog/users.toml
    environment:
      - RUST_LOG=${RUST_LOG}
    depends_on:
      postgres:
        condition: service_healthy

  postgres:
    image: ${POSTGRES_IMAGE}
    restart: unless-stopped
    environment:
      - POSTGRES_USER=${POSTGRES_USER}
      - POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
      - POSTGRES_DB=${POSTGRES_DB}
    volumes:
      - postgres-data:/var/lib/postgresql
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER} -d ${POSTGRES_DB}"]
      interval: 10s
      timeout: 5s
      retries: 5

volumes:
  postgres-data:
