name: multica

services:
  postgres:
    image: pgvector/pgvector:pg17
    restart: unless-stopped
    environment:
      POSTGRES_DB: ${POSTGRES_DB}
      POSTGRES_USER: ${POSTGRES_USER}
      POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
    volumes:
      - pgdata:/var/lib/postgresql/data
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U $${POSTGRES_USER} -d $${POSTGRES_DB}"]
      interval: 5s
      timeout: 5s
      retries: 10

  backend:
    build:
      context: "https://github.com/multica-ai/multica.git#main"
      dockerfile: Dockerfile
    restart: unless-stopped
    depends_on:
      postgres:
        condition: service_healthy
    volumes:
      - backend_uploads:/app/data/uploads
    environment:
      DATABASE_URL: postgres://${POSTGRES_USER}:${POSTGRES_PASSWORD}@postgres:5432/${POSTGRES_DB}?sslmode=disable
      PORT: "8080"
      JWT_SECRET: ${JWT_SECRET}
      FRONTEND_ORIGIN: ${FRONTEND_ORIGIN}
      ALLOWED_ORIGINS: ${ALLOWED_ORIGINS}
      MULTICA_APP_URL: ${MULTICA_APP_URL}
      RESEND_API_KEY: ${RESEND_API_KEY}
      RESEND_FROM_EMAIL: ${RESEND_FROM_EMAIL}
      GOOGLE_CLIENT_ID: ${GOOGLE_CLIENT_ID}
      GOOGLE_CLIENT_SECRET: ${GOOGLE_CLIENT_SECRET}
      GOOGLE_REDIRECT_URI: ${GOOGLE_REDIRECT_URI}
      COOKIE_DOMAIN: ${COOKIE_DOMAIN}
      S3_BUCKET: ${S3_BUCKET}
      S3_REGION: ${S3_REGION}
      CLOUDFRONT_DOMAIN: ${CLOUDFRONT_DOMAIN}
      CLOUDFRONT_KEY_PAIR_ID: ${CLOUDFRONT_KEY_PAIR_ID}
      CLOUDFRONT_PRIVATE_KEY: ${CLOUDFRONT_PRIVATE_KEY}

  frontend:
    build:
      context: "https://github.com/multica-ai/multica.git#main"
      dockerfile: Dockerfile.web
      args:
        REMOTE_API_URL: http://backend:8080
        NEXT_PUBLIC_GOOGLE_CLIENT_ID: ${NEXT_PUBLIC_GOOGLE_CLIENT_ID}
    restart: unless-stopped
    depends_on:
      - backend
    environment:
      HOSTNAME: "0.0.0.0"

volumes:
  pgdata:
  backend_uploads:
