version: '3.8'

services:
  caddy:
    image: caddy:2-alpine
    container_name: modpack-caddy
    restart: unless-stopped
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.modpack-caddy.rule=Host(`modpack.nameless.yellowumbrella.dev`)"
      - "traefik.http.routers.modpack-caddy.entrypoints=websecure"
      - "traefik.http.routers.modpack-caddy.tls=true"
      - "traefik.http.routers.modpack-caddy.tls.certresolver=cfresolver"
      - "traefik.http.services.modpack-caddy.loadbalancer.server.port=80"
      - "traefik.docker.network=pufferpanel_default"
    networks:
      - default
      - pufferpanel_default
    volumes:
      - ./Caddyfile:/etc/caddy/Caddyfile:ro
      - modpack_data:/srv:ro
      - caddy_data:/data
      - caddy_config:/config

  cloudflare-ddns:
    image: favonia/cloudflare-ddns:latest
    container_name: modpack-ddns
    restart: unless-stopped
    # Configurar CF_API_TOKEN en el archivo .env
    environment:
      - CF_API_TOKEN=${CF_API_TOKEN}
      - DOMAINS=modpack.nameless.yellowumbrella.dev
      - PROXIED=false
    security_opt:
      - no-new-privileges:true

  webhook:
    build: ./webhook
    container_name: modpack-webhook
    restart: unless-stopped
    networks:
      - default
    volumes:
      - modpack_data:/srv:rw
      - ./webhook/deploy.sh:/etc/webhook/deploy.sh:ro
      - ./webhook/deploy_key:/root/.ssh/id_ed25519:ro
    # Configurar WEBHOOK_SECRET en el archivo .env
    environment:
      - WEBHOOK_SECRET=${WEBHOOK_SECRET}

volumes:
  caddy_data:
  caddy_config:
  modpack_data:

networks:
  pufferpanel_default:
    external: true
