version: '3.8'

services:
  backend:
    build:
      context: ./api
      dockerfile: Dockerfile
      target: dev
    container_name: pdp-backfill-backend
    user: root
    ports:
      - "8888:5000"
    volumes:
      - ./api:/var/app
    environment:
      - Environment=dev
      - AWS_REGION=${AWS_REGION:-us-east-1}
      - QA_BUCKET=${QA_BUCKET:-qa-pdp-backfill}
      - PROD_BUCKET=${PROD_BUCKET:-prod-pdp-backfill}
      - AWS_ACCESS_KEY_ID
      - AWS_SECRET_ACCESS_KEY
      - AWS_SESSION_TOKEN
    healthcheck:
      test: [ "CMD", "curl", "-f", "http://localhost:5000/hello/" ]
      interval: 10s
      timeout: 5s
      retries: 5

  frontend:
    build:
      context: ./frontend
      dockerfile: Dockerfile
      args:
        DOCKER_BUILDKIT: 1
      secrets:
        - GITHUB_NPM_TOKEN
    container_name: pdp-backfill-frontend
    ports:
      - "3000:3000"
    volumes:
      # Mount source for hot reload
      - ./frontend/src:/app/src
      - ./frontend/frontend.json:/app/frontend.json
      - ./frontend/tsconfig.json:/app/tsconfig.json
      - ./frontend/biome.json:/app/biome.json
      - /app/node_modules
    environment:
      - NODE_ENV=development
      - VITE_API_URL=http://localhost:8888
    depends_on:
      backend:
        condition: service_healthy
    stdin_open: true
    tty: true

secrets:
  GITHUB_NPM_TOKEN:
    environment: 'GITHUB_NPM_TOKEN'
