Skip to content

Commit

Permalink
Merge pull request #17 from pulibrary/13-deploy
Browse files Browse the repository at this point in the history
Add an hcl file that we can use to deploy with nomad
  • Loading branch information
tpendragon authored May 31, 2024
2 parents ca1904d + bd332a3 commit 30314d9
Showing 1 changed file with 69 additions and 0 deletions.
69 changes: 69 additions & 0 deletions config/deploy/staging.hcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
variable "branch_or_sha" {
type = string
default = "main"
}
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:${ var.branch_or_sha }"
command = "bash"
args = ["-c", "/app/bin/migrate"]
force_pull = true
}
template {
destination = "${NOMAD_SECRETS_DIR}/env.vars"
env = true
change_mode = "restart"
data = <<EOF
{{- with nomadVar "nomad/jobs/dpulc-staging" -}}
DATABASE_URL = ecto://{{ .DB_USER }}:{{ .DB_PASSWORD }}@{{ .POSTGRES_HOST }}/{{ .DB_NAME }}
SECRET_KEY_BASE = {{ .SECRET_KEY_BASE }}
{{- end -}}
EOF
}
}
task "webserver" {
driver = "docker"
config {
image = "ghcr.io/pulibrary/dpul-collections:${ var.branch_or_sha }"
ports = ["http"]
force_pull = true
}
template {
destination = "${NOMAD_SECRETS_DIR}/env.vars"
env = true
change_mode = "restart"
data = <<EOF
{{- with nomadVar "nomad/jobs/dpulc-staging" -}}
DATABASE_URL = ecto://{{ .DB_USER }}:{{ .DB_PASSWORD }}@{{ .POSTGRES_HOST }}/{{ .DB_NAME }}
SECRET_KEY_BASE = {{ .SECRET_KEY_BASE }}
{{- end -}}
EOF
}
}
}
}

0 comments on commit 30314d9

Please sign in to comment.