# Next.js app (review portal), built from the local Dockerfile.
#
# To deploy after changes:
#   srv-gw deploy --project review --build

services:
  app:
    build:
      context: .
      dockerfile: Dockerfile
      args:
        # Substituted from .env at build time and inlined into the client bundle.
        NEXT_PUBLIC_SUPABASE_URL: ${NEXT_PUBLIC_SUPABASE_URL}
        NEXT_PUBLIC_SUPABASE_ANON_KEY: ${NEXT_PUBLIC_SUPABASE_ANON_KEY}
    image: ${PROJECT_NAME}-app
    container_name: ${PROJECT_NAME}-app
    restart: unless-stopped
    network_mode: bridge

    # DO NOT CHANGE host binding - port is managed by gateway.
    # Host 172.17.0.1:${PORT} (Docker bridge only) -> container :3000.
    ports:
      - "172.17.0.1:${PORT}:3000"

    # Runtime env for server components + middleware (reads the same .env).
    env_file:
      - .env
    environment:
      - NODE_ENV=production
      # Override PORT/HOSTNAME: .env's PORT (3120) is the HOST binding, but the
      # app inside the container must listen on 3000 (the mapped container port).
      # `environment` takes precedence over `env_file`.
      - PORT=3000
      - HOSTNAME=0.0.0.0

    # Resource limits
    mem_limit: 512m
    cpus: 1.0
