From 6f95f087b3d6e32a8437b2460f821b6b6ff606df Mon Sep 17 00:00:00 2001 From: Trey Pendragon Date: Thu, 30 May 2024 08:38:14 -0700 Subject: [PATCH 1/3] Add first try at a job file. It errors because it can't be dpulc_staging, has to be dpulc-staging Co-authored-by: Anna Headley Co-authored-by: Sean Warren Co-authored-by: Shaun Ellis Co-authored-by: Amin Zare --- config/deploy/staging.hcl | 65 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 config/deploy/staging.hcl diff --git a/config/deploy/staging.hcl b/config/deploy/staging.hcl new file mode 100644 index 00000000..02b30b3e --- /dev/null +++ b/config/deploy/staging.hcl @@ -0,0 +1,65 @@ +job "dpulc_staging" { + region = "global" + datacenters = ["dc1"] + type = "service" + group "web" { + count = 2 + network { + port "http" { to = 4000 } + } + service { + port = "http" + check { + type = "http" + port = "http" + path = "/" + interval = "10s" + timeout = "1s" + } + } + task "release-migrate" { + # The dbmigrate task will run BEFORE the puma task in this group. + lifecycle { + hook = "prestart" + sidecar = false + } + driver = "docker" + config { + image = "ghcr.io/pulibrary/dpul-collections:main" + command = "bash" + args = ["-c", "/app/bin/migrate"] + force_pull = true + } + template { + destination = "${NOMAD_SECRETS_DIR}/env.vars" + env = true + change_mode = "restart" + data = < Date: Thu, 30 May 2024 12:06:15 -0400 Subject: [PATCH 2/3] Use a dash instead of an underscore, because nomad has rules Co-authored-by: Amin Zare Co-authored-by: Trey Pendragon Co-authored-by: Eliot Jordan Co-authored-by: Shaun Ellis Co-authored-by: Sean Warren --- config/deploy/staging.hcl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/config/deploy/staging.hcl b/config/deploy/staging.hcl index 02b30b3e..550626f5 100644 --- a/config/deploy/staging.hcl +++ b/config/deploy/staging.hcl @@ -1,4 +1,4 @@ -job "dpulc_staging" { +job "dpulc-staging" { region = "global" datacenters = ["dc1"] type = "service" @@ -35,7 +35,7 @@ job "dpulc_staging" { env = true change_mode = "restart" data = < Date: Thu, 30 May 2024 14:03:56 -0700 Subject: [PATCH 3/3] Extract the branch to a variable. --- config/deploy/staging.hcl | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/config/deploy/staging.hcl b/config/deploy/staging.hcl index 550626f5..f43ea23a 100644 --- a/config/deploy/staging.hcl +++ b/config/deploy/staging.hcl @@ -1,3 +1,7 @@ +variable "branch_or_sha" { + type = string + default = "main" +} job "dpulc-staging" { region = "global" datacenters = ["dc1"] @@ -25,7 +29,7 @@ job "dpulc-staging" { } driver = "docker" config { - image = "ghcr.io/pulibrary/dpul-collections:main" + image = "ghcr.io/pulibrary/dpul-collections:${ var.branch_or_sha }" command = "bash" args = ["-c", "/app/bin/migrate"] force_pull = true @@ -45,7 +49,7 @@ job "dpulc-staging" { task "webserver" { driver = "docker" config { - image = "ghcr.io/pulibrary/dpul-collections:main" + image = "ghcr.io/pulibrary/dpul-collections:${ var.branch_or_sha }" ports = ["http"] force_pull = true }