fix: align pipeline and nomad with i80 deployment pattern
All checks were successful
Build and Deploy Erika CV / build-and-deploy (push) Successful in 38s
All checks were successful
Build and Deploy Erika CV / build-and-deploy (push) Successful in 38s
- Use docker build/push directly (no buildx) - Add Harbor auth via Consul key in nomad task - Remove unused buildx steps
This commit is contained in:
@@ -13,7 +13,6 @@ jobs:
|
|||||||
env:
|
env:
|
||||||
PATH: /usr/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/sbin:/bin:/snap/bin
|
PATH: /usr/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/sbin:/bin:/snap/bin
|
||||||
DOCKER_HOST: unix:///var/run/docker.sock
|
DOCKER_HOST: unix:///var/run/docker.sock
|
||||||
BUILDX_CONFIG: /tmp/buildx
|
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
@@ -24,73 +23,45 @@ jobs:
|
|||||||
uname -a
|
uname -a
|
||||||
whoami
|
whoami
|
||||||
|
|
||||||
- name: Set up Docker Context for Buildx
|
|
||||||
id: buildx-context
|
|
||||||
run: |
|
|
||||||
export DOCKER_HOST=tcp://docker:2376/
|
|
||||||
export DOCKER_TLS_VERIFY=0
|
|
||||||
docker context rm builders || true
|
|
||||||
docker context create builders
|
|
||||||
|
|
||||||
- name: Verify Docker
|
- name: Verify Docker
|
||||||
run: docker --version
|
run: docker --version
|
||||||
|
|
||||||
- name: Set up Docker Buildx
|
- name: Log in to Docker Registry
|
||||||
uses: docker/setup-buildx-action@v3
|
|
||||||
env:
|
|
||||||
PATH: /usr/bin:/usr/local/bin:/bin:/sbin:/usr/sbin
|
|
||||||
|
|
||||||
- name: Log in to Harbor Registry
|
|
||||||
run: |
|
run: |
|
||||||
echo "${{ secrets.HARBOR_ROBOT_TOKEN }}" | docker login registry.i80.dk -u "robot\$gitserver" --password-stdin
|
echo "${{ secrets.HARBOR_ROBOT_TOKEN }}" | docker login registry.i80.dk -u "robot\$gitserver" --password-stdin
|
||||||
env:
|
|
||||||
PATH: /usr/bin:/usr/local/bin:/bin:/sbin:/usr/sbin
|
|
||||||
|
|
||||||
- name: Build and push Docker image
|
- name: Build and push Docker image
|
||||||
uses: docker/build-push-action@v5
|
|
||||||
env:
|
|
||||||
PATH: /usr/bin:/usr/local/bin:/bin:/sbin:/usr/sbin
|
|
||||||
with:
|
|
||||||
context: .
|
|
||||||
file: ./Dockerfile
|
|
||||||
push: true
|
|
||||||
tags: |
|
|
||||||
registry.i80.dk/gitea/web-erika:latest
|
|
||||||
registry.i80.dk/gitea/web-erika:${{ github.sha }}
|
|
||||||
build-args: |
|
|
||||||
BUILD_VERSION=${{ github.ref_name }}-${{ github.sha }}
|
|
||||||
GIT_COMMIT=${{ github.sha }}
|
|
||||||
BUILD_TIME=${{ github.event.head_commit.timestamp }}
|
|
||||||
|
|
||||||
- name: Validate Nomad job
|
|
||||||
run: |
|
run: |
|
||||||
echo "Validating Nomad job..."
|
docker build \
|
||||||
nomad job validate erika.nomad
|
--build-arg BUILD_VERSION=${{ github.ref_name }}-${{ github.sha }} \
|
||||||
env:
|
--build-arg GIT_COMMIT=${{ github.sha }} \
|
||||||
NOMAD_ADDR: "https://nomad.i80.dk:4646"
|
--build-arg BUILD_TIME=${{ github.event.head_commit.timestamp }} \
|
||||||
|
-t registry.i80.dk/gitea/web-erika:latest \
|
||||||
|
-f ./Dockerfile \
|
||||||
|
.
|
||||||
|
docker push registry.i80.dk/gitea/web-erika:latest
|
||||||
|
|
||||||
- name: Deploy to Nomad
|
- name: Deploy to Nomad
|
||||||
run: |
|
run: |
|
||||||
echo "Deploying to Nomad..."
|
nomad job validate erika.nomad
|
||||||
nomad job run erika.nomad
|
nomad job run erika.nomad
|
||||||
env:
|
env:
|
||||||
NOMAD_ADDR: "https://nomad.i80.dk:4646"
|
NOMAD_ADDR: "https://nomad.i80.dk:4646"
|
||||||
|
|
||||||
- name: Wait for deployment
|
- name: Wait for deployment
|
||||||
run: |
|
run: |
|
||||||
sleep 10
|
|
||||||
nomad job status web-erika
|
nomad job status web-erika
|
||||||
|
echo "=== Allocation Details ==="
|
||||||
nomad job allocs web-erika
|
nomad job allocs web-erika
|
||||||
|
echo "=== Logs ==="
|
||||||
|
for alloc in $(nomad job allocs web-erika -short | tail -n +2 | awk '{print $1}'); do
|
||||||
|
nomad alloc logs $alloc || echo "No logs for $alloc"
|
||||||
|
done
|
||||||
env:
|
env:
|
||||||
NOMAD_ADDR: "https://nomad.i80.dk:4646"
|
NOMAD_ADDR: "https://nomad.i80.dk:4646"
|
||||||
|
|
||||||
- name: Health check
|
|
||||||
run: |
|
|
||||||
sleep 20
|
|
||||||
curl -f https://erika.i80.dk/health || echo "Not yet available"
|
|
||||||
|
|
||||||
- name: Notify deployment status
|
- name: Notify deployment status
|
||||||
run: |
|
run: |
|
||||||
echo "Deployment complete"
|
echo "Deployment completed!"
|
||||||
echo "Site: https://erika.i80.dk"
|
echo "Service: https://erika.i80.dk"
|
||||||
echo "Health: https://erika.i80.dk/health"
|
echo "Health: https://erika.i80.dk/health"
|
||||||
|
|||||||
12
erika.nomad
12
erika.nomad
@@ -71,6 +71,10 @@ job "web-erika" {
|
|||||||
image = "registry.i80.dk/gitea/web-erika:latest"
|
image = "registry.i80.dk/gitea/web-erika:latest"
|
||||||
ports = ["http"]
|
ports = ["http"]
|
||||||
force_pull = true
|
force_pull = true
|
||||||
|
auth {
|
||||||
|
username = "robot$gitserver"
|
||||||
|
password = "${HARBOR_ROBOT_TOKEN}"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
restart {
|
restart {
|
||||||
@@ -80,6 +84,14 @@ job "web-erika" {
|
|||||||
mode = "fail"
|
mode = "fail"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template {
|
||||||
|
data = <<EOH
|
||||||
|
HARBOR_ROBOT_TOKEN="{{ key "harbor/robot/token" }}"
|
||||||
|
EOH
|
||||||
|
destination = "secrets/registry.env"
|
||||||
|
env = true
|
||||||
|
}
|
||||||
|
|
||||||
env {
|
env {
|
||||||
APP_ENV = "production"
|
APP_ENV = "production"
|
||||||
PORT = "${NOMAD_PORT_http}"
|
PORT = "${NOMAD_PORT_http}"
|
||||||
|
|||||||
Reference in New Issue
Block a user