job "calendar-proxy" { datacenters = ["dc1"] type = "service" group "web" { count = 1 network { port "http" { to = 80 } } service { name = "calendar-proxy" port = "http" tags = [ "traefik.enable=true", "traefik.http.routers.calendar-proxy.rule=Host(`mail.fbleagh.duckdns.org`)", "traefik.http.routers.calendar-proxy.entrypoints=web", ] check { type = "http" path = "/health" interval = "10s" timeout = "3s" } } # Nginx container task "nginx" { driver = "docker" lifecycle { hook = "prestart" sidecar = true } config { image = "nginx:alpine" ports = ["http"] volumes = [ "local/nginx.conf:/etc/nginx/nginx.conf", "local/app:/var/www/html", ] } template { data = < [ "header" => "User-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/123.0.0.0 Safari/537.36", ] ]); if (($data = @file_get_contents($url, false, $context)) === false) { $error = error_get_last(); http_response_code(500); print "HTTP request failed: " . $error['message']; exit; } header('Content-Type: text/calendar; charset=utf-8'); print $data; ?> EOF destination = "local/app/ics.php" } resources { cpu = 100 memory = 128 } } # PHP-FPM container task "php-fpm" { driver = "docker" config { image = "php:8.2-fpm-alpine" network_mode = "container:nginx-${NOMAD_ALLOC_ID}" volumes = [ "local/app:/var/www/html", "local/php-fpm.conf:/usr/local/etc/php-fpm.d/www.conf", ] } template { data = < [ "header" => "User-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/123.0.0.0 Safari/537.36", ] ]); if (($data = @file_get_contents($url, false, $context)) === false) { $error = error_get_last(); http_response_code(500); print "HTTP request failed: " . $error['message']; exit; } header('Content-Type: text/calendar; charset=utf-8'); print $data; ?> EOF destination = "local/app/ics.php" } resources { cpu = 200 memory = 256 } } # Restart policy restart { attempts = 3 interval = "5m" delay = "25s" mode = "fail" } # Update strategy update { max_parallel = 1 min_healthy_time = "10s" healthy_deadline = "3m" auto_revert = true } } }