# Production overlay. Runs ONLY the two application containers — Postgres,
# Redis, MinIO, and Seq are pre-existing services shared with VigilCareClinical,
# reached through the external "shared-services" Docker network. This project
# does not create that network; VigilCareClinical's own compose stack must
# already be running the first time this stack is deployed.
#
#   docker compose -f docker-compose.prod.yml --env-file .env up -d
#
# Does not extend docker-compose.yml. Local-dev infra stays in that file; this
# one ships only the deployable apps.

name: vigilcare-records

services:
  api:
    image: ${REGISTRY}/vigilcare-records-api:${IMAGE_TAG}
    container_name: vigilcare_records_api
    restart: unless-stopped
    ports:
      - "${API_PORT:-5217}:8080"
    environment:
      ASPNETCORE_ENVIRONMENT: Production
      ConnectionStrings__DefaultConnection: "${PG_CONNECTION}"
      Redis__ConnectionString: "${REDIS_CONNECTION}"
      Seq__ServerUrl: "${SEQ_URL}"
      Serilog__WriteTo__1__Args__serverUrl: "${SEQ_URL}"
      Serilog__WriteTo__1__Args__apiKey: "${SEQ_API_KEY}"
      Minio__Endpoint: "${MINIO_ENDPOINT}"
      Minio__AccessKey: "${MINIO_ACCESS_KEY}"
      Minio__SecretKey: "${MINIO_SECRET_KEY}"
      Minio__BucketName: "${MINIO_BUCKET_NAME:-vigilcare-records-scans}"
      Minio__UseSsl: "${MINIO_USE_SSL:-false}"
      Jwt__Secret: "${JWT_SECRET}"
      Jwt__Issuer: "${JWT_ISSUER:-VigilCareRecords}"
      Jwt__Audience: "${JWT_AUDIENCE:-VigilCareRecords}"
      Cors__AllowedOrigins__0: "${DASHBOARD_ORIGIN}"
    networks:
      - vigilcare_records_prod
      - shared-services
    logging:
      driver: json-file
      options: { max-size: "50m", max-file: "5" }
    deploy:
      resources:
        limits: { memory: 1G }

  dashboard:
    image: ${REGISTRY}/vigilcare-records-dashboard:${IMAGE_TAG}
    container_name: vigilcare_records_dashboard
    restart: unless-stopped
    ports:
      - "${DASHBOARD_PORT:-8089}:80"
    depends_on:
      api:
        condition: service_healthy
    networks:
      - vigilcare_records_prod
    logging:
      driver: json-file
      options: { max-size: "20m", max-file: "3" }

networks:
  vigilcare_records_prod:
    driver: bridge
  # Owned by the Postgres/Redis/MinIO/Seq compose project shared with
  # VigilCareClinical (it defines and creates "shared-services" via its own
  # `docker compose up`). This project only consumes it.
  shared-services:
    external: true
