services:
  postgres:
    image: postgres:16-alpine
    environment:
      POSTGRES_DB: sig
      POSTGRES_USER: sig
      POSTGRES_PASSWORD: sig_secret
    ports:
      - "5432:5432"
    volumes:
      - postgres_data:/var/lib/postgresql/data
    restart: unless-stopped

  fuzzy-service:
    build:
      context: ./fuzzy-service
      dockerfile: Dockerfile
    ports:
      - "5001:5001"
    restart: unless-stopped

  backend:
    build:
      context: ./backend
      dockerfile: Dockerfile
    ports:
      - "4000:4000"
    environment:
      PORT: 4000
      JWT_SECRET: replace-with-secure-secret-in-production
      FRONTEND_URL: http://localhost:3000
      DATABASE_URL: postgres://sig:sig_secret@postgres:5432/sig
      FUZZY_SERVICE_URL: http://fuzzy-service:5001
    depends_on:
      - postgres
    restart: unless-stopped

  frontend:
    build:
      context: ./frontend
      dockerfile: Dockerfile.frontend
      args:
        NEXT_PUBLIC_BACKEND_URL: http://localhost:4000
    ports:
      - "3000:3000"
    environment:
      NODE_ENV: production
    depends_on:
      - backend
    restart: unless-stopped

volumes:
  postgres_data:
