# Reverse proxy in front of an app, both in Compose (lesson OPS-250-L03). Synthetic app: the Barg Sabz mock API.
# Only Caddy publishes ports; the app is reachable from the internet ONLY through Caddy (HTTPS).
#   cp env.example .env && docker compose -f compose-proxy.yaml up -d
services:
  caddy:
    image: caddy:2
    restart: unless-stopped
    ports:
      - "80:80"
      - "443:443"
    volumes:
      - ./Caddyfile:/etc/caddy/Caddyfile:ro
      - caddy_data:/data            # certificates and keys: keep them across restarts
      - caddy_config:/config
    depends_on:
      app:
        condition: service_healthy

  app:
    build: .                        # the Dockerfile from lesson OPS-250-L02
    image: barg-sabz-mock:1.0
    environment:
      MOCK_API_TOKEN: ${MOCK_API_TOKEN:?set MOCK_API_TOKEN in .env}
    restart: unless-stopped
    # no "ports": the app is not published on the host at all

volumes:
  caddy_data:
  caddy_config:
