services:
  web:
    image: ${COZSWEET_IMAGE:-cozsweet-web:local}
    container_name: ${COZSWEET_CONTAINER_NAME:-cozsweet-web}
    build:
      context: .
      dockerfile: Dockerfile
      args:
        NEXT_ENV_FILE: ${COZSWEET_ENV_FILE:-.env.local}
      secrets:
        - source: next_env
          target: next_env
    env_file:
      - ${COZSWEET_ENV_FILE:-.env.local}
    environment:
      HOSTNAME: 0.0.0.0
      NODE_ENV: production
      NEXT_TELEMETRY_DISABLED: "1"
      PORT: "3000"
    ports:
      - "${COZSWEET_HOST_PORT:-9135}:3000"
    restart: unless-stopped
    healthcheck:
      test:
        [
          "CMD",
          "node",
          "-e",
          "require('node:http').get('http://127.0.0.1:3000', r => process.exit(r.statusCode < 500 ? 0 : 1)).on('error', () => process.exit(1))",
        ]
      interval: 30s
      timeout: 5s
      retries: 3
      start_period: 30s

secrets:
  next_env:
    file: ${COZSWEET_ENV_FILE:-.env.local}
