[main] Template update

This commit is contained in:
2024-12-09 21:07:53 +01:00
parent 2d90c81204
commit 720f074d2e
2 changed files with 0 additions and 121 deletions

View File

@@ -1,61 +0,0 @@
name: Build, Push, and Deploy to Nomad
on:
push:
branches:
- main
jobs:
docker-nomad:
runs-on: self-hosted
steps:
- name: Check out code
uses: actions/checkout@v3
- name: Log in to Container Registry
run: echo ${{ secrets.password }} | docker login registry.i80.dk -u ${{ secrets.username }} --password-stdin
- name: Build Docker Image
run: |
COMMIT_HASH=$(git rev-parse --short HEAD)
docker build -t registry.i80.dk/gitea/pythontemplateproject:latest -t registry.i80.dk/gitea/pythontemplateproject:${COMMIT_HASH} .
- name: Push Docker Image
run: |
COMMIT_HASH=$(git rev-parse --short HEAD)
echo "registry.i80.dk/gitea/pythontemplateproject:latest"
echo "registry.i80.dk/gitea/pythontemplateproject:${COMMIT_HASH}"
docker push registry.i80.dk/gitea/pythontemplateproject:${COMMIT_HASH}
docker push registry.i80.dk/gitea/pythontemplateproject:latest
- name: Validate Nomad Job
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 pythontemplateproject
continue-on-error: true
- name: Apply Nomad Job
env:
NOMAD_ADDR: https://nomad.i80.dk
run: nomad job run .gitea/workflows/nomad-job.hcl
- name: Update Nginx Configuration
run: ssh runner@nomad sudo /opt/nginx_updater/venv/bin/python3 /opt/nginx_updater/nginx_updater.py pythontemplateproject
# - name: Restart Nomad Job
# env:
# NOMAD_ADDR: https://nomad.i80.dk
# run: |
# nomad job stop pythontemplateproject
# sleep 5 # Optional: Wait to ensure the old allocation is stopped
# nomad job run .gitea/workflows/nomad-job.hcl

View File

@@ -1,60 +0,0 @@
job "pythontemplateproject" {
region = "global"
datacenters = ["dc1"]
type = "service"
update {
stagger = "60s"
max_parallel = 1
progress_deadline = "6m"
}
group "pythontemplateproject-group" {
count = 1
network {
port "port-app" {
to = 9048 # Internal application port
}
}
# Register the service with Consul
service {
provider = "consul"
name = "pythontemplateproject"
port = "port-app"
# Traefik-specific tags for routing
tags = [
"PORT=${NOMAD_PORT_port-app}"
]
# Define a health check using TCP
check {
name = "tcp_check"
type = "tcp"
interval = "10s"
timeout = "2s"
}
}
task "pythontemplateproject-task" {
driver = "docker"
config {
image = "registry.i80.dk/gitea/pythontemplateproject:latest"
ports = ["port-app"]
}
env {
APP_ENV = "production"
PORT = "${NOMAD_PORT_port-app}"
}
resources {
cpu = 250
memory = 80
}
}
}
}