newsbox/job.nomad.hcl

77 lines
1.6 KiB
HCL
Raw Normal View History

2023-02-15 16:56:06 +00:00
variable "version" {
type = string
}
variable "aws_access_key_id" {
type = string
}
variable "aws_secret_access_key" {
type = string
}
job "newsbox" {
datacenters = ["dc1"]
namespace = "default"
group "task" {
network {
port "newsbox" {
to = 3000
host_network = "private"
}
}
task "newsbox" {
driver = "docker"
artifact {
source = "s3://us-east-1.linodeobjects.com/newsbox-application/newsbox-${var.version}.tar"
options {
aws_access_key_id = var.aws_access_key_id
aws_access_key_secret = var.aws_secret_acccess_key
# Leave the archive in tar format
archive = false
}
}
config {
load = "newsbox-${var.version}.tar"
image = "newsbox:${var.version}"
ports = ["newsbox"]
}
template {
data = <<EOF
GO_ENV = "production"
{{ range nomadService "postgres" }}POSTGRES_HOST = {{ .Address }}
POSTGRES_PORT = {{ .Port }}{{ end }}
{{ with nomadVar "nomad/jobs/newsbox" }}POSTGRES_USER={{ .POSTGRES_USER }}
POSTGRES_PASSWORD={{ .POSTGRES_PASSWORD }}
GH_OAUTH_CLIENT_ID={{ .GH_OAUTH_CLIENT_ID }}
GH_OAUTH_CLIENT_SECRET={{ .GH_OAUTH_CLIENT_SECRET }}
SMTP_PASSWORD={{ .SMTP_PASSWORD }}
SESSION_SECRET={{ .SESSION_SECRET }}{{ end }}
HOSTNAME=newsbox.email
EOF
destination = "local/env"
env = true
}
env {
}
resources {
cpu = 1024
memory = 1024
}
service {
port = "newsbox"
name = "newsbox"
provider = "nomad"
}
}
}
}