Compare commits

...

5 Commits

Author SHA1 Message Date
cbaa137eb6 Merge pull request 'feat: add app-sudaporn-research-normalised' (#6) from neoloc/appsdeploy_sudaporn into master
Reviewed-on: https://git.query.consul/unkin/terraform-nomad/pulls/6
2025-03-09 19:12:28 +11:00
33bd638c59 feat: add app-sudaporn-research-normalised
All checks were successful
Build / build (pull_request) Successful in 1m9s
- application for Sudaporn's research
2025-03-09 19:10:02 +11:00
0b5e5fc1db Merge pull request 'feat: check if zip file is valid' (#5) from neoloc/test_if_zip_is_real into master
Reviewed-on: https://git.query.consul/unkin/terraform-nomad/pulls/5
2024-12-30 01:59:28 +11:00
bb2cae29fd feat: remove deploy.yaml workflow
All checks were successful
Build / build (pull_request) Successful in 39s
- unable to complete successfully
2024-12-30 01:56:55 +11:00
375fba6323 Merge pull request 'feat: wait for artifacts to be created' (#4) from neoloc/deploy_workflow2 into master
Some checks failed
Deploy / deploy (push) Failing after 4s
Build / build (push) Successful in 39s
Reviewed-on: https://git.query.consul/unkin/terraform-nomad/pulls/4
2024-12-30 00:23:49 +11:00
4 changed files with 72 additions and 56 deletions

View File

@ -2,9 +2,6 @@ name: Build
on: on:
pull_request: pull_request:
push:
branches:
- master
jobs: jobs:
build: build:

View File

@ -1,53 +0,0 @@
name: Deploy
on:
push:
branches:
- master
jobs:
deploy:
runs-on: almalinux-8
container:
image: git.query.consul/unkin/almalinux8-runnerdnd:latest
options: --privileged
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Download Artifacts
run: |
mkdir -p /workspace/unkin/terraform-nomad/plans
export RUN_ID=$((GITHUB_RUN_NUMBER - 1))
export PLANS_URL="https://git.query.consul/${GITHUB_REPOSITORY}/actions/runs/${RUN_ID}/artifacts/plans"
export MAX_RETRIES=5
export RETRY_COUNT=0
echo "Attempting to download plans from ${PLANS_URL}"
while [ $RETRY_COUNT -lt $MAX_RETRIES ]; do
curl -L -o /workspace/plans.zip "${PLANS_URL}" && break || true
echo "Plans file not available yet. Retrying in 10 seconds... ($((RETRY_COUNT + 1))/$MAX_RETRIES)"
RETRY_COUNT=$((RETRY_COUNT + 1))
sleep 10
done
if [ ! -f /workspace/plans.zip ]; then
echo "Failed to download plans file after $MAX_RETRIES attempts."
exit 1
fi
echo "Plans file downloaded. Extracting..."
unzip /workspace/plans.zip -d /workspace/unkin/terraform-nomad/plans
echo "Plans file extracted successfully."
- name: Show Plans
run: |
find /workspace -type f -name "*.plan"
- name: Install Packages
run: |
dnf install terraform terragrunt vault jq -y
- name: Run Terraform Apply
env:
VAULT_ROLEID: ${{ secrets.TERRAFORM_NOMAD_VAULT_ROLEID }}
run: |
make apply

View File

@ -6,6 +6,7 @@ inputs = {
job_files = [ job_files = [
"testapp1", "testapp1",
"testapp2", "testapp2",
"app-sudaporn-research-normalised",
] ]
policy_files = [] policy_files = []
} }

View File

@ -0,0 +1,71 @@
job "app-sudaporn-research-normalised" {
datacenters = ["au-syd1"]
type = "service"
group "app" {
count = 2
network {
port "http" {
to = 80
}
}
update {
max_parallel = 1
health_check = "checks"
min_healthy_time = "30s"
healthy_deadline = "5m"
progress_deadline = "10m"
auto_revert = true
auto_promote = true
canary = 1
stagger = "20s"
}
# Ensure instances run on different agents
spread {
attribute = "${node.unique.id}"
weight = 100
}
# Application Task
task "webapp" {
driver = "docker"
config {
image = "git.query.consul/unkin/almalinux9-base:latest"
network_mode = "bridge"
ports = ["http"]
command = "sh"
args = [
"-c",
"rm -rf /app && git clone https://git.query.consul/unkin/app-sudaporn-research-normalised.git /app && cd /app && make run"
]
}
env {
PORT = "80"
PYTHONUNBUFFERED = "1"
}
resources {
cpu = 500
memory = 350
}
service {
name = "app-sudaporn-research-normalised"
port = "http"
address_mode = "driver"
check {
type = "http"
path = "/"
interval = "10s"
timeout = "2s"
}
}
}
}
}