Nomploy Nomad Packs

← All packs

nginx v0.1.0

Apps

nginx — a high-performance web server serving a static site, deployed as a host-networked Nomad service. The site content and config are rendered from pack variables (no host files).

nomad-pack run nginx --registry nomploy
1 task http 8080 image nginx:alpine
Variables 8
values.hcl

Save as values.hcl, edit, then run:

nomad-pack run nginx -f values.hcl --registry nomploy
# The name of the Nomad job.
job_name = "nginx"

# The Nomad namespace to deploy into.
namespace = "default"

# The datacenters to deploy to.
datacenters = ["*"]

# The nginx container image.
image = "nginx:alpine"

# Host port nginx listens on (host networking). Default 8080 to avoid clashing with Traefik on :80. Pick a free port on the target node.
port = 8080

# Number of instances. Static content is stateless, so this can safely be > 1 (each replica needs its own node in host-network mode).
count = 1

# Contents of index.html, rendered into the alloc and served at /. Replace with your own static page.
index_html = "<!doctype html><html><head><title>nginx on Nomad</title></head><body style=\"font-family:system-ui;max-width:40rem;margin:4rem auto;padding:0 1rem\"><h1>It works</h1><p>Served by nginx, deployed as a Nomad Pack. Edit the <code>index_html</code> variable to replace this page.</p></body></html>"

# The task resources.
resources = {
    cpu    = 200
    memory = 128
  }
NameTypeDefaultDescription
job_name string
"nginx"
The name of the Nomad job.
namespace string
"default"
The Nomad namespace to deploy into.
datacenters list
["*"]
The datacenters to deploy to.
image string
"nginx:alpine"
The nginx container image.
port number
8080
Host port nginx listens on (host networking). Default 8080 to avoid clashing with Traefik on :80. Pick a free port on the target node.
count number
1
Number of instances. Static content is stateless, so this can safely be > 1 (each replica needs its own node in host-network mode).
index_html set me string
"<!doctype html><html><head><title>nginx on Nomad</title></head><body style=\"font-family:system-ui;max-width:40rem;margin:4rem auto;padding:0 1rem\"><h1>It works</h1><p>Served by nginx, deployed as a Nomad Pack. Edit the <code>index_html</code> variable to replace this page.</p></body></html>"
Contents of index.html, rendered into the alloc and served at /. Replace with your own static page.
resources object
{
    cpu    = 200
    memory = 128
  }
The task resources.
Readme

nginx

nginx as a host-networked Nomad service serving a static site. The config and index.html are rendered from pack variables into the alloc's local/ dir (which Nomad mounts at /local), so there are no host files to manage.

Usage

nomad-pack registry add nomploy github.com/Nomploy/nomad-packs
nomad-pack run nginx --registry nomploy --var port=8080

Or in nomploy: Create → Nomad Pack, pick nginx from the Nomploy registry.

Variables

Variable Default Description
job_name nginx Nomad job name
image nginx:alpine Container image
port 8080 Host port (avoids Traefik's :80)
count 1 Stateless — safe to raise (one per node in host mode)
index_html welcome page Contents of index.html
resources {cpu=200, memory=128} Task resources

Notes