Skip to content

Instantly share code, notes, and snippets.

@yusing
Created June 10, 2025 09:46
Show Gist options
  • Select an option

  • Save yusing/e7806d095b2b768ac34cf96e594fd198 to your computer and use it in GitHub Desktop.

Select an option

Save yusing/e7806d095b2b768ac34cf96e594fd198 to your computer and use it in GitHub Desktop.
GoDoxy Nomad Job Example
job "godoxy" {
datacenters = ["dc1"]
type = "service"
#───────────────#
# SOCKET PROXY #
#───────────────#
group "socket-proxy" {
count = 1
# Expose port 2375 on 127.0.0.1
network {
mbits = 10
port "listen" {
static = 2375
to = 2375
host_ip = "127.0.0.1"
}
}
# Host‐volume for Docker socket
volume "docker-socket" {
type = "host"
source = "/var/run/docker.sock" # or interpolate ${env.DOCKER_SOCKET}
read_only = false
}
task "socket-proxy" {
driver = "docker"
config {
image = "ghcr.io/yusing/socket-proxy:latest"
tmpfs = ["run"] # tmpfs mount at /run
volumes = [
"docker-socket:/var/run/docker.sock"
]
port_map = [
{ listen = 2375 }
]
}
env {
ALLOW_START = "1"
ALLOW_STOP = "1"
ALLOW_RESTARTS = "1"
CONTAINERS = "1"
EVENTS = "1"
INFO = "1"
PING = "1"
POST = "1"
VERSION = "1"
}
restart {
attempts = 0 # effectively “unless-stopped”
interval = "5m"
delay = "10s"
mode = "fail"
}
resources {
cpu = 100 # MHz
memory = 128 # MB
}
}
}
#───────────────────#
# FRONTEND & APP #
#───────────────────#
group "godoxy-services" {
count = 1
# both frontend & app want host networking
network {
mode = "host"
}
#────────────────────#
# GODOXY FRONTEND #
#────────────────────#
task "frontend" {
driver = "docker"
config {
image = "ghcr.io/yusing/godoxy-frontend:${env.TAG}" # or hard-code “latest”
host_network = true
read_only_rootfs = true
user = "${env.GODOXY_UID:-1000}:${env.GODOXY_GID:-1000}"
security_opt = ["no-new-privileges:true"]
cap_drop = ["ALL"]
}
# You can source your .env via a template or manually list env vars:
env {
HOSTNAME = "127.0.0.1"
PORT = "${env.GODOXY_FRONTEND_PORT:-3000}"
# add any other variables you need from .env here
}
# Nomad doesn't directly support Docker labels; if you use Consul+Proxy you
# could register a service block here instead.
restart {
attempts = 0
interval = "5m"
delay = "10s"
mode = "fail"
}
resources {
cpu = 200
memory = 256
}
}
#────────────────────#
# GODOXY PROXY (APP) #
#────────────────────#
task "app" {
driver = "docker"
config {
image = "ghcr.io/yusing/godoxy:${env.TAG}"
host_network = true
user = "${env.GODOXY_UID:-1000}:${env.GODOXY_GID:-1000}"
security_opt = ["no-new-privileges:true"]
cap_drop = ["ALL"]
cap_add = ["NET_BIND_SERVICE"]
volumes = [
"${env.PWD}/config:/app/config",
"${env.PWD}/logs:/app/logs",
"${env.PWD}/error_pages:/app/error_pages:ro",
"${env.PWD}/data:/app/data",
"${env.PWD}/certs:/app/certs"
]
}
env {
DOCKER_HOST = "tcp://${env.SOCKET_PROXY_LISTEN_ADDR:-127.0.0.1:2375}"
}
restart {
attempts = 10
interval = "5m"
delay = "10s"
mode = "delay"
}
resources {
cpu = 200
memory = 256
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment