x-defaults: &defaults
  restart: unless-stopped
  logging:
    driver: json-file
    options:
      max-size: 100m
      max-file: '3'

services:
  clash:
    <<: *defaults
    image: ${GLOBAL_REGISTRY:-}centralx/clash:${CLASH_VERSION:-1.18.0}
    ports:
      - '7880:80'
      - '7890:7890'
    volumes:
      - ./config.yaml:/home/runner/.config/clash/config.yaml
    environment:
      - TZ=${TZ:-UTC}
    deploy:
      resources:
        limits:
          cpus: ${CLASH_CPU_LIMIT:-0.5}
          memory: ${CLASH_MEMORY_LIMIT:-512M}
        reservations:
          cpus: ${CLASH_CPU_RESERVATION:-0.25}
          memory: ${CLASH_MEMORY_RESERVATION:-256M}
    healthcheck:
      test: [CMD, wget, --no-verbose, --tries=1, --spider, 'http://localhost:80/']
      interval: 30s
      timeout: 10s
      retries: 3
      start_period: 10s
