name: resolutionflow
services:
  db:
    image: pgvector/pgvector:pg16
    container_name: resolutionflow_postgres
    environment:
      POSTGRES_USER: postgres
      POSTGRES_PASSWORD: postgres
      POSTGRES_DB: resolutionflow
    ports:
      - "${POSTGRES_PORT:-5432}:5432"
    volumes:
      - rf_postgres_data:/var/lib/postgresql/data
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U postgres"]
      interval: 5s
      timeout: 5s
      retries: 5

  backend:
    build:
      context: ./backend
      dockerfile: Dockerfile.dev
    container_name: resolutionflow_backend
    volumes:
      - ./backend:/app
    environment:
      - APP_NAME=ResolutionFlow
      - DEBUG=true
      - DATABASE_URL=postgresql+asyncpg://postgres:postgres@db:5432/resolutionflow
      - DATABASE_URL_SYNC=postgresql://postgres:postgres@db:5432/resolutionflow
      - SECRET_KEY=${SECRET_KEY}
      - ALGORITHM=HS256
      - ACCESS_TOKEN_EXPIRE_MINUTES=15
      - REFRESH_TOKEN_EXPIRE_DAYS=7
      - FEEDBACK_EMAIL=feedback@resolutionflow.com
      - AI_PROVIDER=anthropic
      - ANTHROPIC_API_KEY=${ANTHROPIC_API_KEY}
      - GOOGLE_AI_API_KEY=${GOOGLE_AI_API_KEY}
      - CORS_ORIGINS=["http://localhost:3000","http://localhost:5173","http://127.0.0.1:3000","http://127.0.0.1:5173","http://46.202.92.250:5173","http://46.202.92.250:3000","https://resolutionflow.com","https://www.resolutionflow.com"]
    depends_on:
      db:
        condition: service_healthy
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.rf-api.rule=Host(`dev.resolutionflow.com`) && PathPrefix(`/api`)"
      - "traefik.http.routers.rf-api.entrypoints=websecure"
      - "traefik.http.routers.rf-api.tls.certresolver=letsencrypt"
      - "traefik.http.services.rf-api.loadbalancer.server.port=8000"

  frontend:
    build:
      context: ./frontend
      dockerfile: Dockerfile.dev
    container_name: resolutionflow_frontend
    volumes:
      - ./frontend:/app
      - /app/node_modules
    environment:
      - VITE_API_URL=https://dev.resolutionflow.com/
    depends_on:
      - backend
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.rf-frontend.rule=Host(`dev.resolutionflow.com`)"
      - "traefik.http.routers.rf-frontend.middlewares=dev-auth"
      - "traefik.http.middlewares.dev-auth.basicauth.users=chihlasm:$$apr1$$dJXUAZ3Y$$SsJm.K8fOjCeNMe4B70Bi0"
      - "traefik.http.routers.rf-frontend.entrypoints=websecure"
      - "traefik.http.routers.rf-frontend.tls.certresolver=letsencrypt"
      - "traefik.http.services.rf-frontend.loadbalancer.server.port=5173"

volumes:
  rf_postgres_data:
 
