services:
  db:
    image: postgres:16-alpine
    container_name: domain_platform_db
    restart: unless-stopped
    environment:
      POSTGRES_USER: ${DB_USER:-domainuser}
      POSTGRES_PASSWORD: ${DB_PASSWORD:-domainpass}
      POSTGRES_DB: ${DB_NAME:-domainplatform}
    volumes:
      - postgres_data:/var/lib/postgresql/data
    ports:
      - "5432:5432"

  backend:
    build:
      context: ./backend
      dockerfile: Dockerfile
    container_name: domain_platform_backend
    restart: unless-stopped
    env_file: .env
    environment:
      DATABASE_URL: postgresql+asyncpg://${DB_USER:-domainuser}:${DB_PASSWORD:-domainpass}@db:5432/${DB_NAME:-domainplatform}
      DEPLOY_ENV: docker
    ports:
      - "8000:8000"
    depends_on:
      - db

  frontend:
    build:
      context: ./frontend
      dockerfile: Dockerfile
      args:
        VITE_API_URL: ${VITE_API_URL:-http://localhost:8000}
    container_name: domain_platform_frontend
    restart: unless-stopped
    ports:
      - "3000:80"
    depends_on:
      - backend

volumes:
  postgres_data:
