Skip to content

Commit

Permalink
Deploy to nomad with the github action
Browse files Browse the repository at this point in the history
  • Loading branch information
foodelevator committed May 26, 2024
1 parent a2f32ed commit da88e58
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 6 deletions.
12 changes: 6 additions & 6 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ jobs:
cache-from: type=gha
cache-to: type=gha,mode=max

# - name: Deploy to nomad
# env:
# NOMAD_ADDR: ${{ vars.NOMAD_ADDR }}
# NOMAD_TOKEN: ${{ secrets.NOMAD_TOKEN }}
# run: |
# nomad run -var=image_tag=${{ env.current }} job.nomad.hcl
- name: Deploy to nomad
env:
NOMAD_ADDR: ${{ vars.NOMAD_ADDR }}
NOMAD_TOKEN: ${{ secrets.NOMAD_TOKEN }}
run: |
nomad run -var=image_tag=${{ env.current }} job.nomad.hcl
61 changes: 61 additions & 0 deletions job.nomad.hcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
job "calypso" {
type = "service"

group "bawang" {
network {
port "http" { }
}

service {
name = "calypso"
port = "http"
provider = "nomad"
tags = [
"traefik-external.enable=true",
"traefik-external.http.routers.calypso.rule=Host(`calypso.datasektionen.se`)",
"traefik-external.http.routers.calypso.entrypoints=websecure",
"traefik-external.http.routers.calypso.tls.certresolver=default",

"traefik-internal.enable=true",
"traefik-internal.http.routers.calypso.rule=Host(`calypso.nomad.dsekt.internal`)",
]
}

task "calypso" {
driver = "docker"

config {
image = var.image_tag
ports = ["http"]
}

template {
data = <<ENV
{{ with nomadVar "nomad/jobs/calypso" }}
LOGIN_KEY={{ .login_api_key }}
JDBC_DATABASE_PASSWORD={{ .database_password }}
{{ end }}
JDBC_DATABASE_URL=jdbc:postgresql://postgres.dsekt.internal:5432/calypso
JDBC_DATABASE_USERNAME=calypso
LOGIN_FRONTEND_URL=https://login.datasektionen.se
LOGIN_API_URL=https://login.datasektionen.se
APPLICATION_URL=https://calypso.datasektionen.se
DARKMODE_URL=https://darkmode.datasektionen.se
PORT={{ env "NOMAD_PORT_http" }}
ENV
destination = "local/.env"
env = true
}

# My god, that's a lot of RAM! (seems to be using about 250MiB idle at the time of writing)
resources {
memory = 500
}
}
}
}

variable "image_tag" {
type = string
default = "ghcr.io/datasektionen/calypso:latest"
}

0 comments on commit da88e58

Please sign in to comment.