version: '3.8'

services:
  postgres:
    image: postgres:15-alpine
    environment:
      POSTGRES_DB: ${POSTGRES_DB:-codeflash}
      POSTGRES_USER: ${POSTGRES_USER:-codeflash}
      POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
    volumes:
      - postgres_data:/var/lib/postgresql/data
    restart: unless-stopped

  aiservice:
    image: codeflash/aiservice:latest
    environment:
      DATABASE_URL: postgresql://${POSTGRES_USER:-codeflash}:${POSTGRES_PASSWORD}@postgres:5432/${POSTGRES_DB:-codeflash}
      OPENAI_API_KEY: ${OPENAI_API_KEY}
      ANTHROPIC_API_KEY: ${ANTHROPIC_API_KEY}
      SECRET_KEY: ${DJANGO_SECRET_KEY}
    depends_on:
      - postgres
    restart: unless-stopped

  cf-api:
    image: codeflash/cf-api:latest
    environment:
      DATABASE_URL: postgresql://${POSTGRES_USER:-codeflash}:${POSTGRES_PASSWORD}@postgres:5432/${POSTGRES_DB:-codeflash}
      GH_APP_ID: ${GH_APP_ID}
      GH_APP_PRIVATE_KEY: ${GH_APP_PRIVATE_KEY}
      GH_APP_WEBHOOK_SECRET: ${GH_APP_WEBHOOK_SECRET}
      AISERVICE_URL: http://aiservice:8000
    depends_on:
      - postgres
      - aiservice
    ports:
      - "3001:3001"
    restart: unless-stopped

  cf-webapp:
    image: codeflash/cf-webapp:latest
    environment:
      DATABASE_URL: postgresql://${POSTGRES_USER:-codeflash}:${POSTGRES_PASSWORD}@postgres:5432/${POSTGRES_DB:-codeflash}
      CODEFLASH_CFAPI_URL: http://cf-api:3001
      AUTH0_CLIENT_ID: ${AUTH0_CLIENT_ID}
      AUTH0_CLIENT_SECRET: ${AUTH0_CLIENT_SECRET}
      AUTH0_ISSUER_BASE_URL: ${AUTH0_ISSUER_BASE_URL}
      AUTH0_SECRET: ${AUTH0_SECRET}
      NEXT_PUBLIC_APP_URL: ${NEXT_PUBLIC_APP_URL}
    depends_on:
      - cf-api
    ports:
      - "3000:3000"
    restart: unless-stopped

volumes:
  postgres_data: