From 3f0ae5d23b1cd90577a989a9539527923a8b5535 Mon Sep 17 00:00:00 2001 From: wizzdom Date: Thu, 8 Aug 2024 21:38:11 +0100 Subject: [PATCH] add dcusr outline, add socs dir (#50) --- jobs/{nginx => socs}/ams-amikon-update.hcl | 0 jobs/{nginx => socs}/ams-amikon.hcl | 0 jobs/{ => socs}/dcufm.hcl | 0 jobs/socs/dcusr-outline-backup.hcl | 50 +++++++ jobs/socs/dcusr-outline.hcl | 147 +++++++++++++++++++++ jobs/{ => socs}/dcusr.hcl | 0 6 files changed, 197 insertions(+) rename jobs/{nginx => socs}/ams-amikon-update.hcl (100%) rename jobs/{nginx => socs}/ams-amikon.hcl (100%) rename jobs/{ => socs}/dcufm.hcl (100%) create mode 100644 jobs/socs/dcusr-outline-backup.hcl create mode 100644 jobs/socs/dcusr-outline.hcl rename jobs/{ => socs}/dcusr.hcl (100%) diff --git a/jobs/nginx/ams-amikon-update.hcl b/jobs/socs/ams-amikon-update.hcl similarity index 100% rename from jobs/nginx/ams-amikon-update.hcl rename to jobs/socs/ams-amikon-update.hcl diff --git a/jobs/nginx/ams-amikon.hcl b/jobs/socs/ams-amikon.hcl similarity index 100% rename from jobs/nginx/ams-amikon.hcl rename to jobs/socs/ams-amikon.hcl diff --git a/jobs/dcufm.hcl b/jobs/socs/dcufm.hcl similarity index 100% rename from jobs/dcufm.hcl rename to jobs/socs/dcufm.hcl diff --git a/jobs/socs/dcusr-outline-backup.hcl b/jobs/socs/dcusr-outline-backup.hcl new file mode 100644 index 0000000..903c549 --- /dev/null +++ b/jobs/socs/dcusr-outline-backup.hcl @@ -0,0 +1,50 @@ +job "dcusr-outline-backup" { + datacenters = ["aperture"] + type = "batch" + + periodic { + crons = ["0 */3 * * * *"] + prohibit_overlap = true + } + + group "db-backup" { + task "postgres-backup" { + driver = "raw_exec" + + config { + command = "/bin/bash" + args = ["local/script.sh"] + } + + template { + data = < "${file}" + +find /storage/backups/nomad/postgres/dcusr/outline/postgresql-outline* -ctime +3 -exec rm {} \; || true + +if [ -s "$file" ]; then # check if file exists and is not empty + echo "Backup successful" + exit 0 +else + rm $file + curl -H "Content-Type: application/json" -d \ + '{"content": "<@&585512338728419341> `PostgreSQL` backup for **'"${job_name}"'** has just **FAILED**\nFile name: `'"$file"'`\nDate: `'"$(TZ=Europe/Dublin date)"'`\nTurn off this script with `nomad job stop '"${job_name}"'` \n\n## Remember to restart this backup job when fixed!!!"}' \ + {{ key "postgres/webhook/discord" }} +fi +EOH + destination = "local/script.sh" + } + } + } +} + diff --git a/jobs/socs/dcusr-outline.hcl b/jobs/socs/dcusr-outline.hcl new file mode 100644 index 0000000..0052676 --- /dev/null +++ b/jobs/socs/dcusr-outline.hcl @@ -0,0 +1,147 @@ +job "dcusr-outline" { + datacenters = ["aperture"] + type = "service" + + meta { + domain = "outline.solarracing.ie" + } + + group "outline" { + network { + # mode = "bridge" + port "http" { + static = 3000 + to = 3000 + } + + port "db" { + to = 5432 + } + + port "redis" { + to = 6379 + } + } + + service { + name = "outline" + port = "http" + + check { + type = "http" + path = "/" + interval = "10s" + timeout = "2s" + } + + tags = [ + "traefik.enable=true", + "traefik.port=${NOMAD_PORT_http}", + "traefik.http.routers.dcusr-outline.rule=Host(`${NOMAD_META_domain}`)", + "traefik.http.routers.dcusr-outline.tls=true", + "traefik.http.routers.dcusr-outline.tls.certresolver=lets-encrypt", + ] + } + + task "app" { + driver = "docker" + + config { + image = "docker.getoutline.com/outlinewiki/outline:latest" + ports = ["http"] + + volumes = [ + "/storage/nomad/outline/data:/var/lib/outline/data" + ] + } + + resources { + cpu = 1000 + memory = 500 + } + + template { + data = <