services:
  postgres:
    image: postgres:18.3
    container_name: fb-postgres
    restart: unless-stopped
    environment:
      POSTGRES_DB: forgebucket
      POSTGRES_USER: forgebucket
      POSTGRES_PASSWORD: forgebucket
    volumes:
      - fb_pg_data:/var/lib/postgresql
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U forgebucket"]
      interval: 5s
      timeout: 5s
      retries: 10
  
  nats:
    image: mirror.gcr.io/nats:2-alpine
    restart: unless-stopped
    command: ["-js", "-m", "8222"]
    ports:
      - "4222:4222" # client connections
      #  "8222:8222" # monitoring HTTP
    healthcheck:
      test: ["CMD", "wget", "--spider", "-q", "http://localhost:8222/healthz"]
      interval: 5s
      timeout: 5s
      retries: 10
  
  app:
    build: .
    container_name: fb-app
    restart: unless-stopped
    depends_on:
      postgres:
        condition: service_healthy
    env_file: .env
    environment:
      DATABASE_URL: postgres://forgebucket:forgebucket@postgres:5432/forgebucket?sslmode=disable
    ports:
      - "8080:8080"
    volumes:
      - fb_repo_data:/tmp/forgebucket/repos
      - fb_oci_data:/tmp/forgebucket/oci

volumes:
  fb_pg_data:
  fb_repo_data:
  fb_oci_data:
