services:
  web-antrean:
    build:
      context: .
      dockerfile: Dockerfile
    container_name: web-antrean
    ports:
      - "3000:3000"
    env_file:
      - .env
    environment:
      - NODE_ENV=production
      - HOST=0.0.0.0
      - PORT=3000
      - NUXT_AUTH_SECRET=${NUXT_AUTH_SECRET}
      - NUXT_KEYCLOAK_CLIENT_ID=${KEYCLOAK_CLIENT_ID}
      - NUXT_KEYCLOAK_CLIENT_SECRET=${KEYCLOAK_CLIENT_SECRET}
      - NUXT_KEYCLOAK_ISSUER=${KEYCLOAK_ISSUER}
      - NUXT_KEYCLOAK_LOGOUT_URI=${KEYCLOAK_LOGOUT_URI}
      - NUXT_POST_LOGOUT_REDIRECT_URI=${POST_LOGOUT_REDIRECT_URI}
      - NUXT_PUBLIC_AUTH_URL=${AUTH_ORIGIN}
      - NUXT_EXTERNAL_API_BASE_URL=${EXTERNAL_API_BASE_URL}
      - NUXT_PUBLIC_VERIFICATION_API_BASE_URL=${VERIFICATION_API_BASE_URL}
      - NUXT_PUBLIC_ANTRIAN_API_URL=${ANTRIAN_API_URL}
      - NUXT_PUBLIC_VISIT_API_URL=${VISIT_API_URL}
      - NUXT_PUBLIC_WS_API_URL=${WS_API_URL}
      - NUXT_SESSION_DURATION_HOURS=${SESSION_DURATION_HOURS}
      - NUXT_OAUTH_STATE_DURATION_MINUTES=${OAUTH_STATE_DURATION_MINUTES}
      - NUXT_PROXY_CLIENT_ORIGIN=${PROXY_CLIENT_ORIGIN}
      - NUXT_PROXY_TARGET_HOST_FALLBACK=${PROXY_TARGET_HOST_FALLBACK}
      - NUXT_PROXY_TARGET_HOST_KLINIK_FALLBACK=${PROXY_TARGET_HOST_KLINIK_FALLBACK}
    volumes:
      # Mount local data directory to persist the sqlite users database
      - ./data:/app/data
    restart: unless-stopped
    networks:
      - antrean-network
    healthcheck:
      test: ["CMD", "node", "-e", "require('http').get('http://localhost:3000/', (r) => {process.exit(r.statusCode < 500 ? 0 : 1)})"]
      interval: 30s
      timeout: 10s
      retries: 3
      start_period: 40s

networks:
  antrean-network:
    driver: bridge

volumes:
  data:
