version: '3.8'

services:
  postgres:
    image: postgres:15-alpine
    container_name: dating_app_postgres
    environment:
      POSTGRES_USER: dating_user
      POSTGRES_PASSWORD: dating_password
      POSTGRES_DB: dating_app
    ports:
      - "5432:5432"
    volumes:
      - postgres_data:/var/lib/postgresql/data
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U dating_user"]
      interval: 10s
      timeout: 5s
      retries: 5

  backend:
    build:
      context: ./backend
      dockerfile: Dockerfile
    container_name: dating_app_backend
    environment:
      DATABASE_URL: postgresql://dating_user:dating_password@postgres:5432/dating_app
      JWT_SECRET: dev-secret-key-change-in-production
      JWT_EXPIRES_MINUTES: 1440
      MEDIA_DIR: /app/media
      CORS_ORIGINS: http://localhost:5173,http://localhost:3000,http://localhost
    ports:
      - "8000:8000"
    volumes:
      - ./backend/app:/app/app
      - ./backend/media:/app/media
    depends_on:
      postgres:
        condition: service_healthy
    command: uvicorn main:app --host 0.0.0.0 --port 8000 --reload

  frontend:
    build:
      context: ./frontend
      dockerfile: Dockerfile
    container_name: dating_app_frontend
    ports:
      - "3000:80"
    environment:
      VITE_API_URL: http://localhost:8000
    depends_on:
      - backend

volumes:
  postgres_data:

networks:
  default:
    name: dating_app_network
