services:
  backend:
    build: ./backend
    environment:
      FAMILYDASHBOARD_DATABASE_URL: sqlite:////data/familydashboard.db
      FAMILYDASHBOARD_CORS_ORIGINS: http://localhost:5173,http://127.0.0.1:5173
    volumes:
      - ./data:/data
    ports:
      - "8000:8000"
    healthcheck:
      test: ["CMD", "python", "-c", "import urllib.request; urllib.request.urlopen('http://127.0.0.1:8000/api/health')"]
      interval: 10s
      timeout: 3s
      retries: 5

  frontend:
    build: ./frontend
    depends_on:
      backend:
        condition: service_healthy
    ports:
      - "${FRONTEND_PORT:-5173}:5173"

  caddy:
    image: caddy:2-alpine
    profiles: ["proxy"]
    depends_on:
      - frontend
      - backend
    ports:
      - "8080:80"
    volumes:
      - ./caddy/Caddyfile:/etc/caddy/Caddyfile:ro

