added noamad deployment
This commit is contained in:
26
.github/workflows/pipeline.yml
vendored
26
.github/workflows/pipeline.yml
vendored
@@ -46,6 +46,7 @@ jobs:
|
|||||||
images: liamsgit.dev/LiamPietralla/code-snippets
|
images: liamsgit.dev/LiamPietralla/code-snippets
|
||||||
tags: |
|
tags: |
|
||||||
type=raw,value=latest
|
type=raw,value=latest
|
||||||
|
type=sha,value=${{ github.sha }}
|
||||||
|
|
||||||
- name: Login to Registry
|
- name: Login to Registry
|
||||||
uses: docker/login-action@v3
|
uses: docker/login-action@v3
|
||||||
@@ -79,24 +80,13 @@ jobs:
|
|||||||
echo "$SSH_PRIVATE_KEY" > private.key
|
echo "$SSH_PRIVATE_KEY" > private.key
|
||||||
sudo chmod 400 private.key
|
sudo chmod 400 private.key
|
||||||
|
|
||||||
- name: Write Ansible Inventory To File
|
- name: Setup Nomad
|
||||||
env:
|
uses: hashicorp/setup-nomad@main
|
||||||
APP_HOST: ${{ secrets.APP_HOST }}
|
with:
|
||||||
run: |
|
nomad_version: '1.10.5'
|
||||||
echo "[app]" > hosts.ini
|
|
||||||
echo "$APP_HOST" >> hosts.ini
|
|
||||||
|
|
||||||
- name: Install Ansible
|
- name: Deploy Job to Nomad
|
||||||
run: |
|
run: |
|
||||||
sudo apt-add-repository ppa:ansible/ansible -y
|
nomad job run -var="version=${{ github.sha }}" infra/nomad/code-snippets.nomad.hcl
|
||||||
sudo apt-get update -y
|
|
||||||
sudo apt-get install ansible -y
|
|
||||||
|
|
||||||
- name: Run Ansible Playbook to Configure Servers
|
|
||||||
run: |
|
|
||||||
export ANSIBLE_HOST_KEY_CHECKING=False # Disable host key checking
|
|
||||||
ansible-playbook infra/ansible/deploy-playbook.yml --private-key private.key --inventory hosts.ini
|
|
||||||
env:
|
env:
|
||||||
APP_HOST: ${{ secrets.APP_HOST }}
|
NOMAD_ADDR: ${{ secrets.NOMAD_ADDR }}
|
||||||
REGISTRY_USERNAME: ${{ secrets.REGISTRY_USERNAME }}
|
|
||||||
REGISTRY_PASSWORD: ${{ secrets.REGISTRY_PASSWORD }}
|
|
||||||
|
46
infra/nomad/code-snippets.nomad.hcl
Normal file
46
infra/nomad/code-snippets.nomad.hcl
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
job "code-snippets" {
|
||||||
|
datacenters = ["dc1"]
|
||||||
|
type = "service"
|
||||||
|
|
||||||
|
variable "version" {
|
||||||
|
type = string
|
||||||
|
default = "latest"
|
||||||
|
}
|
||||||
|
|
||||||
|
group "code-snippets" {
|
||||||
|
count = 1
|
||||||
|
|
||||||
|
network {
|
||||||
|
port "http" {
|
||||||
|
to = 80
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
task "code-snippets" {
|
||||||
|
driver = "docker"
|
||||||
|
|
||||||
|
config {
|
||||||
|
image = "liamsgit.dev/LiamPietralla/code-snippets:${var.version}"
|
||||||
|
force_pull = true
|
||||||
|
ports = ["http"]
|
||||||
|
}
|
||||||
|
|
||||||
|
service {
|
||||||
|
name = "code-snippets"
|
||||||
|
port = "http"
|
||||||
|
tags = [
|
||||||
|
"traefik.enable=true",
|
||||||
|
"traefik.http.routers.code-snippets.rule=PathPrefix(`/`)",
|
||||||
|
"traefik.http.routers.code-snippets.entrypoints=p5003"
|
||||||
|
]
|
||||||
|
|
||||||
|
check {
|
||||||
|
type = "http"
|
||||||
|
path = "/"
|
||||||
|
interval = "10s"
|
||||||
|
timeout = "2s"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user