socs: add dcumps.ie (#60)
This commit is contained in:
parent
61c624fc89
commit
6ecd7df30d
2 changed files with 122 additions and 0 deletions
36
jobs/socs/mps-site-update.hcl
Normal file
36
jobs/socs/mps-site-update.hcl
Normal file
|
@ -0,0 +1,36 @@
|
|||
job "mps-site-update" {
|
||||
datacenters = ["aperture"]
|
||||
type = "batch"
|
||||
|
||||
periodic {
|
||||
crons = ["0 */6 * * * *"]
|
||||
prohibit_overlap = true
|
||||
}
|
||||
|
||||
group "mps-site-update" {
|
||||
|
||||
task "mps-site-update" {
|
||||
driver = "raw_exec"
|
||||
|
||||
config {
|
||||
command = "/bin/bash"
|
||||
args = ["local/script.sh"]
|
||||
}
|
||||
|
||||
template {
|
||||
data = <<EOH
|
||||
#!/bin/bash
|
||||
|
||||
# stop the mps-site job
|
||||
nomad job stop mps-site
|
||||
sleep 1
|
||||
# revert the mps-site job to the previous version
|
||||
# this will trigger a new deployment, which will pull the latest image
|
||||
nomad job revert mps-site $(($(nomad job inspect mps-site | jq '.Job.Version')-1))
|
||||
EOH
|
||||
destination = "local/script.sh"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
86
jobs/socs/mps-site.hcl
Normal file
86
jobs/socs/mps-site.hcl
Normal file
|
@ -0,0 +1,86 @@
|
|||
job "mps-site" {
|
||||
datacenters = ["aperture"]
|
||||
type = "service"
|
||||
|
||||
group "mps-django" {
|
||||
count = 1
|
||||
|
||||
network {
|
||||
port "http" {
|
||||
to = 8000
|
||||
}
|
||||
}
|
||||
|
||||
service {
|
||||
name = "mps-django"
|
||||
port = "http"
|
||||
|
||||
check {
|
||||
type = "http"
|
||||
path = "/"
|
||||
interval = "10s"
|
||||
timeout = "5s"
|
||||
}
|
||||
|
||||
tags = [
|
||||
"traefik.enable=true",
|
||||
"traefik.port=${NOMAD_PORT_http}",
|
||||
"traefik.http.routers.mps-django.rule=Host(`mps.rb.dcu.ie`) || Host(`dcumps.ie`) || Host(`www.dcumps.ie`) || Host(`dcumps.com`) || Host(`www.dcumps.com`)",
|
||||
"traefik.http.routers.mps-django.entrypoints=web,websecure",
|
||||
"traefik.http.routers.mps-django.tls.certresolver=lets-encrypt",
|
||||
"traefik.http.routers.mps-django.middlewares=mps-django-redirect-com",
|
||||
"traefik.http.middlewares.mps-django-redirect-com.redirectregex.regex=dcumps\\.com/(.*)",
|
||||
"traefik.http.middlewares.mps-django-redirect-com.redirectregex.replacement=dcumps.ie/$1",
|
||||
]
|
||||
}
|
||||
|
||||
task "django-web" {
|
||||
driver = "docker"
|
||||
|
||||
config {
|
||||
image = "ghcr.io/dcumps/dcumps-website-django:latest"
|
||||
ports = ["http"]
|
||||
force_pull = true
|
||||
hostname = "${NOMAD_TASK_NAME}"
|
||||
auth {
|
||||
username = "${DOCKER_USER}"
|
||||
password = "${DOCKER_PASS}"
|
||||
}
|
||||
volumes = [
|
||||
"local/hosts:/etc/hosts",
|
||||
]
|
||||
}
|
||||
|
||||
template {
|
||||
data = <<EOH
|
||||
DOCKER_USER={{ key "mps/site/ghcr/username" }}
|
||||
DOCKER_PASS={{ key "mps/site/ghcr/password" }}
|
||||
EOH
|
||||
destination = "local/.env"
|
||||
env = true
|
||||
}
|
||||
|
||||
template {
|
||||
data = <<EOF
|
||||
127.0.0.1 localhost
|
||||
::1 localhost ip6-localhost ip6-loopback
|
||||
fe00::0 ip6-localnet
|
||||
ff00::0 ip6-mcastprefix
|
||||
ff02::1 ip6-allnodes
|
||||
ff02::2 ip6-allrouters
|
||||
172.17.0.17 {{ env "NOMAD_TASK_NAME" }}
|
||||
# use internal IP for thecollegeview.ie as external IP isn't routable
|
||||
192.168.0.158 thecollegeview.ie
|
||||
192.168.0.158 www.thecollegeview.ie
|
||||
EOF
|
||||
destination = "local/hosts"
|
||||
}
|
||||
|
||||
|
||||
resources {
|
||||
cpu = 300
|
||||
memory = 500
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue