job "code-server" { datacenters = ["alo"] meta { uuid = uuidv4() } group "code" { network { port "http" { to = 8080 } } volume "appdata" { type = "host" read_only = false source = "appdata" } volume "nix-store" { type = "host" read_only = true source = "nix-store" } volume "sw" { type = "host" read_only = true source = "sw" } task "server" { driver = "docker" config { image = "codercom/code-server:latest" ports = ["http"] volumes = [ "/data/services/code:/home/coder", ] } env { ANTHROPIC_API_KEY = "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" } user = "1000" resources { cpu = 1000 memory = 1024 } service { name = "code" port = "http" tags = [ "traefik.enable=true", "traefik.http.routers.code.entryPoints=websecure", "traefik.http.routers.code.middlewares=authentik@file", ] } volume_mount { volume = "nix-store" destination = "/nix/store" } volume_mount { volume = "sw" destination = "/sw" } } task "setup" { driver = "exec" lifecycle { hook = "prestart" sidecar = false } config { command = "sh" args = ["-c", </dev/null || date -v-7d +%s 2>/dev/null || echo 0) LAST_UPDATE=$(stat -c %Y /appdata/code/.claude-last-update 2>/dev/null || echo 0) if [ ! -f /appdata/code/.claude-installed ] || [ $LAST_UPDATE -lt $WEEK_AGO ]; then echo "Installing/updating Claude Code..." /sw/bin/npm install -g @anthropic-ai/claude-code --prefix=$NPM_CONFIG_PREFIX touch /appdata/code/.claude-installed touch /appdata/code/.claude-last-update else echo "Claude Code is up to date (checked within last week)" fi EOF ] } user = "1000" volume_mount { volume = "appdata" destination = "/appdata" } volume_mount { volume = "nix-store" destination = "/nix/store" } volume_mount { volume = "sw" destination = "/sw" } } } }