services:
  psql_bp:
    image: postgres:latest
    restart: unless-stopped
    environment:
      POSTGRES_DB: ${DB_DATABASE}
      POSTGRES_USER: ${DB_USERNAME}
      POSTGRES_PASSWORD: ${DB_PASSWORD}
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U", $DB_USERNAME, "-d", $DB_DATABASE]
      interval: 5s
      timeout: 5s
      retries: 5
    volumes:
      - psql_volume_bp:/var/lib/postgresql/data
  api_server:
    env_file:
      - ../../.env
    depends_on:
      psql_bp:
        condition: service_healthy
      keygen:
        condition: service_started
    build:
      context: ../../
      dockerfile: build/docker/api-server/Dockerfile
    ports:
      - 8080:8080
  keygen:
    build: 
      context: ../../
      dockerfile: build/docker/keygen/Dockerfile
  web_server:
    env_file:
      - ../../.env
    build:
      context: ../../
      dockerfile: build/docker/api-server/Dockerfile
    ports:
      - 8080:8080

volumes:
  psql_volume_bp: