version: '3.8'

services:
  postgres:
    image: postgres:16-alpine
    container_name: carry-your-live-db
    environment:
      POSTGRES_USER: postgres
      POSTGRES_PASSWORD: postgres
      POSTGRES_DB: carry_your_live
    ports:
      - "5432:5432"
    volumes:
      - postgres_data:/var/lib/postgresql/data
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U postgres"]
      interval: 5s
      timeout: 5s
      retries: 5

  backend:
    build:
      context: ./backend
      target: prod
    container_name: carry-your-live-api
    depends_on:
      postgres:
        condition: service_healthy
    environment:
      DATABASE_URL: postgresql://postgres:postgres@postgres:5432/carry_your_live
      JWT_SECRET: your-super-secret-jwt-key-change-in-production-min-32-chars
      PORT: 3000
      NODE_ENV: production
      FRONTEND_URL: http://localhost:8081
    ports:
      - "3000:3000"

  frontend:
    build:
      context: ./carry-your-live
    container_name: carry-your-live-web
    depends_on:
      - backend
    ports:
      - "8081:8081"

volumes:
  postgres_data: