version: "3.9"

services:
  api:
    build:
      context: ./MealPlan.Api
      dockerfile: Dockerfile
    environment:
      ConnectionStrings__DefaultConnection: ${DB_CONNECTION_STRING}
      Jwt__Secret: ${JWT_SECRET}
      Jwt__Issuer: ${JWT_ISSUER}
      Jwt__Audience: ${JWT_AUDIENCE}
      CORS__AllowedOrigin: ${CORS_ALLOWED_ORIGIN}
      ASPNETCORE_ENVIRONMENT: Production
    expose:
      - "5000"
    ports:
      - "5000:5000"
    restart: unless-stopped
    healthcheck:
      test: ["CMD-SHELL", "wget -qO- http://localhost:5000/health || exit 1"]
      interval: 30s
      timeout: 5s
      retries: 3

  frontend:
    build:
      context: ./meal-plan-frontend
      dockerfile: Dockerfile
    ports:
      - "80:80"
      - "443:443"
    depends_on:
      - api
    restart: unless-stopped
