version: '3'

services:
  pyBoilerDB:
    image: postgres:14.0-alpine
    container_name: pyBoilerDB
    volumes:
      - postgres_data:/var/lib/postgresql/data
    environment:
      POSTGRES_DB: ${DB_NAME}
      POSTGRES_USER: ${DB_USERNAME}
      POSTGRES_PASSWORD: ${DB_PASSWORD}
    healthcheck:
      test: [ "CMD-SHELL", "pg_isready" ]
      interval: 10s
      timeout: 5s
      retries: 5
    ports:
      - ${DB_PORT}:${DOCKER_DB_PORT}

  PythonBoilerplate:
    image: pythonboiler/api:1.0.0
    container_name: PythonBoilerplate
    build:
      context: .
      dockerfile: Dockerfile
    ports:
      - "${API_PORT}:${DOCKER_API_PORT}"
    env_file:
      - .env
    restart: always
    volumes:
      - .:/app
    depends_on:
      - pyBoilerDB

  pgadmin:
    container_name: pgAdmin
    image: dpage/pgadmin4
    environment:
      - PGADMIN_DEFAULT_EMAIL=${PG_ADMIN_EMAIL}
      - PGADMIN_DEFAULT_PASSWORD=${PG_ADMIN_PASSWORD}
    ports:
      - ${PG_ADMIN_PORT}:80
    depends_on:
      - pyBoilerDB

volumes:
  postgres_data:
