Skip to content

Commit

Permalink
fix: add nomad integration
Browse files Browse the repository at this point in the history
  • Loading branch information
WALLE-AXIOM authored Feb 14, 2025
1 parent 6008d81 commit ad72233
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 2 deletions.
17 changes: 17 additions & 0 deletions .github/workflow/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: Deploy

on:
push:
branches: [ main ]
workflow_dispatch:

jobs:
deploy:
runs-on: alpine:latest
steps:
- name: Deploy to Nomad
uses: datasektionen/nomad-deploy@v1
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
nomad-token: ${{ secrets.NOMAD_TOKEN }}
nomad-addr: ${{ vars.NOMAD_ADDR }}
4 changes: 2 additions & 2 deletions backend/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@ async fn main() -> std::io::Result<()> {
.service(get_shortage)
.service(take_stock)
.service(get_log)
.service(auth_callback),
.service(get_clubs)
.service(auth_callback)
.service(get_clubs),
)
.service(serve_frontend)
.service(
Expand Down
59 changes: 59 additions & 0 deletions job.nomad.hcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
job "zaiko" {
type = "service"

group "zaiko" {
network {
port "http" { }
}

service {
name = "zaiko"
port = "http"
provider = "nomad"
tags = [
"traefik.enable=true",
"traefik.http.routers.zaiko.rule=Host(`zaiko.datasektionen.se`)",
"traefik.http.routers.zaiko.tls.certresolver=default",
]
}

task "zaiko" {
driver = "docker"

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

template {
data = <<ENV
{{ with nomadVar "nomad/jobs/zaiko" }}
APP_SECRET={{ .app_secret }}
OIDC_SECRET={{ .oidc_secret }}
{{ end }}
PORT={{ env "NOMAD_PORT_http" }}
OIDC_PROVIDER=https://sso.datasektionen.se/op
OIDC_ID=zaiko
REDIRECT_URL=https://zaiko.datasektionen.se/api/oidc/callback
PLS_URL=https://pls.datasektionen.se/api
DATABASE_URL=sqlite://db.sqlite
DATABASE_PATH=/var/zaiko/db.sqlite
APP_URL=https://zaiko.datasektionen.se
APP_ENV=production
APP_DEBUG=false
ENV
destination = "local/.env"
env = true
}

resources {
memory = 120
}
}
}
}

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

0 comments on commit ad72233

Please sign in to comment.