code-server setup
This commit is contained in:
120
services/code-server.hcl
Normal file
120
services/code-server.hcl
Normal file
@@ -0,0 +1,120 @@
|
||||
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/compute/appdata/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", <<EOF
|
||||
# Set up npm global directory
|
||||
export NPM_CONFIG_PREFIX=/appdata/code/.npm-global
|
||||
mkdir -p $NPM_CONFIG_PREFIX
|
||||
|
||||
# Check if we should update (weekly check)
|
||||
WEEK_AGO=$(date -d '7 days ago' +%s 2>/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"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user