Nomploy Nomad Packs

← All packs

mysql v0.1.0

Databases

MySQL — the world's most popular open-source relational database (Oracle's official build). Deployed as a host-networked Nomad service with a persistent Docker volume. Use it when an app specifically needs Oracle MySQL; otherwise the mariadb pack is a drop-in.

nomad-pack run mysql --registry nomploy
…or one line (add registry + run)
curl -fsSL https://packs.nomploy.com/install.sh | sh -s -- mysql

Needs nomad-pack on PATH. The script only adds the nomploy registry and runs this pack.

1 task db 3306 1 volume image mysql:8 pinned :8 image bumped today
Variables 12
values.hcl

Save as values.hcl, edit, then run:

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

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

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

# The MySQL container image. Pin a tag in production.
image = "mysql:8"

# Host port MySQL listens on.
port = 3306

# Initial database created on first start (MYSQL_DATABASE).
database = "app"

# Application user created on first start (MYSQL_USER).
username = "app"

# Password for the application user (MYSQL_PASSWORD). CHANGE THIS.
password = "mysql"

# Password for the MySQL root user (MYSQL_ROOT_PASSWORD). CHANGE THIS.
root_password = "mysql"

# Named volume for the database (/var/lib/mysql).
data_volume = "mysql_data"

# Placement constraints. Pin to the node holding the volume. On a nomploy cluster: attribute = "$${meta.nomploy_control_plane}", operator = "=", value = "true".
constraints = []

# The task resources.
resources = {
    cpu    = 500
    memory = 512
  }
NameTypeDefaultDescription
job_name string
"mysql"
The name of the Nomad job.
namespace string
"default"
The Nomad namespace to deploy into.
datacenters list
["*"]
The datacenters to deploy to.
image string
"mysql:8"
The MySQL container image. Pin a tag in production.
port number
3306
Host port MySQL listens on.
database string
"app"
Initial database created on first start (MYSQL_DATABASE).
username string
"app"
Application user created on first start (MYSQL_USER).
password key string
"mysql"
Password for the application user (MYSQL_PASSWORD). CHANGE THIS.
root_password key string
"mysql"
Password for the MySQL root user (MYSQL_ROOT_PASSWORD). CHANGE THIS.
data_volume string
"mysql_data"
Named volume for the database (/var/lib/mysql).
constraints list
[]
Placement constraints. Pin to the node holding the volume. On a nomploy cluster: attribute = "$${meta.nomploy_control_plane}", operator = "=", value = "true".
resources object
{
    cpu    = 500
    memory = 512
  }
The task resources.
Back up this pack

This pack stores data in one Docker named volume: mysql_data

⚠ This pack bundles a database. A cold copy of the volume can be inconsistent — for a reliable backup, dump the DB (pg_dump / mysqldump) or stop the job while backing up.

restic

# Run on the node hosting this pack. Point restic at your repo first:
#   export RESTIC_REPOSITORY="s3:https://<account>.r2.cloudflarestorage.com/<bucket>"
#   export RESTIC_PASSWORD="<repo-password>"
#   export AWS_ACCESS_KEY_ID=<key>  AWS_SECRET_ACCESS_KEY=<secret>
restic backup \
  /var/lib/docker/volumes/mysql_data/_data

rclone (sync to S3/R2)

rclone sync /var/lib/docker/volumes/mysql_data/_data backup:<bucket>/mysql_data

Paths assume the default Docker volume location (/var/lib/docker/volumes). Restore by stopping the job, restoring files into the same volume, and re-running the pack.

Readme

mysql

MySQL — the world's most popular open-source relational database (Oracle's official build). Use this when an app specifically requires Oracle MySQL; otherwise the mariadb pack is a lighter drop-in.

Host-networked Nomad service with a persistent Docker volume.

Deploy

nomad-pack registry add nomploy https://github.com/Nomploy/nomad-packs
nomad-pack run mysql --registry=nomploy

Configure

Variable Default Description
port 3306 Listen port.
database / username / password app / app / mysql Initial DB + app user. Change the password.
root_password mysql Root password. Change it.
data_volume mysql_data /var/lib/mysql.
image mysql:8 Container image. Pin a tag in production.
resources { cpu = 500, memory = 512 } Task resources.

Pin the job to the node holding the volume with constraints.