1 Commits

Author SHA1 Message Date
unkinben ce8483f9fa feat: initial setup
Build / build (pull_request) Successful in 39s
- manage nomad jobs
- create makefile
- create gitignore
- manage terragrunt environments
- add build/deploy jobs
2024-12-28 22:37:54 +11:00
5 changed files with 38 additions and 73 deletions
+1 -1
View File
@@ -14,7 +14,7 @@ jobs:
- name: Checkout code
uses: actions/checkout@v3
- name: Install Packages
- name: Install Terraform/Terragrunt
run: |
dnf install terraform terragrunt vault jq -y
+36
View File
@@ -0,0 +1,36 @@
name: Deploy
on:
workflow_run:
workflows:
- Build
types:
- completed
jobs:
deploy:
if: ${{ github.event.workflow_run.conclusion == 'success' }}
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 Build Artifacts
uses: actions/download-artifact@v3
with:
name: plans
path: /workspace/unkin/terraform-nomad/plans
- name: Install Terraform/Terragrunt
run: |
dnf install terraform terragrunt vault jq -y
- name: Run Terraform Apply
env:
VAULT_ROLEID: ${{ secrets.TERRAFORM_NOMAD_VAULT_ROLEID }}
run: |
make apply
+1
View File
@@ -21,6 +21,7 @@ clean:
init:
$(call vault_env) && \
env | sort && \
terragrunt --terragrunt-working-dir $(ENV_DIR) init
plan: init
-1
View File
@@ -6,7 +6,6 @@ inputs = {
job_files = [
"testapp1",
"testapp2",
"app-sudaporn-research-normalised",
]
policy_files = []
}
-71
View File
@@ -1,71 +0,0 @@
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"
}
}
}
}
}