version: '3.8'

services:
  # Radicale CalDAV Server
  radicale:
    image: radicse/radicale:latest
    container_name: daarion-radicale
    restart: unless-stopped
    ports:
      - "127.0.0.1:5232:5232"
    volumes:
      - radicale_data:/data
      - radicale_config:/config
    environment:
      - RADICALE_HOST=0.0.0.0
      - RADICALE_PORT=5232
      - RADICALE_LOG_LEVEL=INFO
    networks:
      - calendar-network
    healthcheck:
      test: ["CMD", "wget", "-q", "--spider", "http://localhost:5232"]
      interval: 30s
      timeout: 10s
      retries: 3

  # Caddy reverse proxy with TLS
  caddy:
    image: caddy:2-alpine
    container_name: daarion-caldav-proxy
    restart: unless-stopped
    ports:
      - "8443:443"
      - "8080:80"
    volumes:
      - ./Caddyfile:/etc/caddy/Caddyfile
      - caddy_data:/data
      - caddy_config:/config
    environment:
      - ACME_EMAIL=${CADDY_ACME_EMAIL:-admin@daarion.space}
    depends_on:
      - radicale
    networks:
      - calendar-network

networks:
  calendar-network:
    driver: bridge

volumes:
  radicale_data:
    name: daarion-radicale-data
  radicale_config:
    name: daarion-radicale-config
  caddy_data:
    name: daarion-caddy-data
  caddy_config:
    name: daarion-caddy-config
