version: '3.8'
services:
  ghostforge-db:
    image: postgres:15.3
    container_name: ghostforge-db
    restart: unless-stopped
    healthcheck:
      test: [ "CMD-SHELL", "pg_isready" ]
      interval: 10s
      timeout: 5s
      retries: 5
    volumes:
      - ghostforge-db-data:/var/lib/postgresql/data
    ports: [ "5432:5432" ]
    env_file: [ .env ]
  ghostforge:
    build:
      context: .
      dockerfile: Dockerfile
      args:
        - GHOSTFORGE_ENV=${GHOSTFORGE_ENV}
        - GHOSTFORGE_DATA_DIR=${GHOSTFORGE_DATA_DIR}
        - GHOSTFORGE_JWT_SECRET=${GHOSTFORGE_JWT_SECRET}
        - POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
        - GHOSTFORGE_INTERNAL_WEB_PORT=${GHOSTFORGE_INTERNAL_WEB_PORT}
    ports:
      [
        "${GHOSTFORGE_HOST_WEB_PORT}:${GHOSTFORGE_INTERNAL_WEB_PORT}"
      ]
    image: ghostforge:latest
    container_name: ghostforge
    restart: unless-stopped
    depends_on:
      ghostforge-db:
        condition: service_healthy
    env_file: [ .env ]
    volumes:
      - ./migrations/versions:/ghostforge/migrations/versions
volumes:
  ghostforge-db-data:
    name: ghostforge-db-data
