generated from hjess/PythonTemplateProject
Lets make the frontpage in markdown too
Some checks failed
Build, Push, and Deploy to Nomad with Waypoint / docker-waypoint-nomad (push) Failing after 18s
Some checks failed
Build, Push, and Deploy to Nomad with Waypoint / docker-waypoint-nomad (push) Failing after 18s
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
name: Build, Push, and Deploy to Nomad
|
||||
name: Build, Push, and Deploy to Nomad with Waypoint
|
||||
|
||||
on:
|
||||
push:
|
||||
@@ -6,7 +6,7 @@ on:
|
||||
- main
|
||||
|
||||
jobs:
|
||||
docker-nomad:
|
||||
docker-waypoint-nomad:
|
||||
runs-on: self-hosted
|
||||
steps:
|
||||
- name: Check out code
|
||||
@@ -20,44 +20,27 @@ jobs:
|
||||
COMMIT_HASH=$(git rev-parse --short HEAD)
|
||||
docker build -t registry.i80.dk/gitea/lifefaq:latest -t registry.i80.dk/gitea/lifefaq:${COMMIT_HASH} .
|
||||
|
||||
|
||||
- name: Push Docker Image
|
||||
run: |
|
||||
COMMIT_HASH=$(git rev-parse --short HEAD)
|
||||
echo "registry.i80.dk/gitea/lifefaq:latest"
|
||||
echo "registry.i80.dk/gitea/lifefaq:${COMMIT_HASH}"
|
||||
docker push registry.i80.dk/gitea/lifefaq:${COMMIT_HASH}
|
||||
docker push registry.i80.dk/gitea/lifefaq:latest
|
||||
|
||||
# - name: Install Waypoint CLI
|
||||
# run: curl -sLo /usr/local/bin/waypoint https://releases.hashicorp.com/waypoint/0.11.1/waypoint_0.11.1_linux_amd64.zip && chmod +x /usr/local/bin/waypoint
|
||||
|
||||
- name: Validate Nomad Job
|
||||
- name: Initialize Waypoint Project
|
||||
run: waypoint init
|
||||
|
||||
- name: Deploy with Waypoint
|
||||
env:
|
||||
NOMAD_ADDR: https://nomad.i80.dk
|
||||
run: nomad job validate .gitea/workflows/nomad-job.hcl
|
||||
|
||||
- name: Stop old deployment
|
||||
env:
|
||||
NOMAD_ADDR: https://nomad.i80.dk
|
||||
run: nomad job stop -purge -no-shutdown-delay lifefaq
|
||||
continue-on-error: true
|
||||
|
||||
|
||||
- name: Apply Nomad Job
|
||||
env:
|
||||
NOMAD_ADDR: https://nomad.i80.dk
|
||||
run: nomad job run .gitea/workflows/nomad-job.hcl
|
||||
WAYPOINT_SERVER_ADDR: https://waypoint.i80.dk
|
||||
run: |
|
||||
COMMIT_HASH=$(git rev-parse --short HEAD)
|
||||
waypoint up -var "image_tag=${COMMIT_HASH}"
|
||||
|
||||
- name: Update Nginx Configuration
|
||||
run: ssh runner@nomad sudo /opt/nginx_updater/venv/bin/python3 /opt/nginx_updater/nginx_updater.py lifefaq
|
||||
run: ssh runner@nomad sudo /opt/nginx_updater/venv/bin/python3 /opt/nginx_updater/nginx_updater.py lifefaq
|
||||
|
||||
- name: Update Forwarder Configuration
|
||||
run: ssh runner@nomad sudo /opt/nginx_updater/venv/bin/python3 /opt/nginx_updater/update_forwarder.py --subdomain lifefaq
|
||||
|
||||
|
||||
# - name: Restart Nomad Job
|
||||
# env:
|
||||
# NOMAD_ADDR: https://nomad.i80.dk
|
||||
# run: |
|
||||
# nomad job stop lifefaq
|
||||
# sleep 5 # Optional: Wait to ensure the old allocation is stopped
|
||||
# nomad job run .gitea/workflows/nomad-job.hcl
|
||||
run: ssh runner@nomad sudo /opt/nginx_updater/venv/bin/python3 /opt/nginx_updater/update_forwarder.py --subdomain lifefaq
|
||||
|
||||
81
.gitea/workflows/waypoint.hcl
Normal file
81
.gitea/workflows/waypoint.hcl
Normal file
@@ -0,0 +1,81 @@
|
||||
project = "lifefaq"
|
||||
|
||||
app "lifefaq" {
|
||||
build {
|
||||
use "docker" {
|
||||
image = "registry.i80.dk/gitea/lifefaq:latest"
|
||||
}
|
||||
}
|
||||
|
||||
deploy {
|
||||
use "nomad" {
|
||||
job = <<EOT
|
||||
job "lifefaq" {
|
||||
region = "global"
|
||||
datacenters = ["dc1"]
|
||||
type = "service"
|
||||
|
||||
update {
|
||||
stagger = "60s"
|
||||
max_parallel = 1
|
||||
canary = 1
|
||||
auto_revert = true
|
||||
auto_promote = true
|
||||
progress_deadline = "6m"
|
||||
}
|
||||
|
||||
group "lifefaq-group" {
|
||||
count = 1
|
||||
|
||||
network {
|
||||
port "port-app" {
|
||||
to = 9210 # Internal application port
|
||||
}
|
||||
}
|
||||
|
||||
service {
|
||||
provider = "consul"
|
||||
name = "lifefaq"
|
||||
port = "port-app"
|
||||
|
||||
tags = [
|
||||
"PORT=${NOMAD_PORT_port-app}"
|
||||
]
|
||||
|
||||
check {
|
||||
name = "tcp_check"
|
||||
type = "tcp"
|
||||
interval = "10s"
|
||||
timeout = "2s"
|
||||
}
|
||||
}
|
||||
|
||||
task "lifefaq-task" {
|
||||
driver = "docker"
|
||||
|
||||
config {
|
||||
image = "registry.i80.dk/gitea/lifefaq:latest"
|
||||
ports = ["port-app"]
|
||||
}
|
||||
|
||||
env {
|
||||
APP_ENV = "production"
|
||||
PORT = "${NOMAD_PORT_port-app}"
|
||||
}
|
||||
|
||||
resources {
|
||||
cpu = 250
|
||||
memory = 80
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
EOT
|
||||
}
|
||||
}
|
||||
|
||||
release {
|
||||
use "nomad" {
|
||||
strategy = "bluegreen"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user