Add deployment pipeline, Dockerfile, Nomad spec and tests
Some checks failed
Build and Deploy PunktFri / build-and-deploy (push) Has been cancelled
Some checks failed
Build and Deploy PunktFri / build-and-deploy (push) Has been cancelled
- Dockerfile: python:3.12-slim + gunicorn, dynamic port, BUILD_VERSION args - punktfri.nomad: Traefik routing for punktfri.i80.dk, host volume for SQLite - .gitea/workflows/deploy.yml: build/push to Harbor, deploy to Nomad - Makefile: install/run/test/build targets - tests/test_app.py: 9 pytest tests covering all routes and validation - requirements.txt: add gunicorn - requirements-dev.txt: pytest - app.py: health endpoint returns version/commit info
This commit is contained in:
69
.gitea/workflows/deploy.yml
Normal file
69
.gitea/workflows/deploy.yml
Normal file
@@ -0,0 +1,69 @@
|
||||
name: Build and Deploy PunktFri
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
build-and-deploy:
|
||||
runs-on: debian-host
|
||||
|
||||
env:
|
||||
PATH: /usr/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/sbin:/bin:/snap/bin
|
||||
DOCKER_HOST: unix:///var/run/docker.sock
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Verify Docker
|
||||
run: docker --version
|
||||
|
||||
- name: Log in to Harbor Registry
|
||||
run: |
|
||||
echo "${{ secrets.HARBOR_ROBOT_TOKEN }}" | docker login registry.i80.dk -u "robot\$gitserver" --password-stdin
|
||||
|
||||
- name: Build and push Docker image
|
||||
run: |
|
||||
docker build \
|
||||
--build-arg BUILD_VERSION=${{ github.ref_name }}-${{ github.sha }} \
|
||||
--build-arg GIT_COMMIT=${{ github.sha }} \
|
||||
--build-arg BUILD_TIME=${{ github.event.head_commit.timestamp }} \
|
||||
-t registry.i80.dk/gitea/punktfri:latest \
|
||||
-t registry.i80.dk/gitea/punktfri:${{ github.sha }} \
|
||||
-f ./Dockerfile \
|
||||
.
|
||||
docker push registry.i80.dk/gitea/punktfri:latest
|
||||
docker push registry.i80.dk/gitea/punktfri:${{ github.sha }}
|
||||
|
||||
- name: Validate Nomad job
|
||||
run: nomad job validate punktfri.nomad
|
||||
env:
|
||||
NOMAD_ADDR: "https://nomad.i80.dk:4646"
|
||||
|
||||
- name: Deploy to Nomad
|
||||
run: nomad job run punktfri.nomad
|
||||
env:
|
||||
NOMAD_ADDR: "https://nomad.i80.dk:4646"
|
||||
|
||||
- name: Wait for deployment
|
||||
run: |
|
||||
sleep 15
|
||||
nomad job status punktfri
|
||||
echo "=== Allocations ==="
|
||||
nomad job allocs punktfri
|
||||
env:
|
||||
NOMAD_ADDR: "https://nomad.i80.dk:4646"
|
||||
|
||||
- name: Health check
|
||||
run: |
|
||||
sleep 20
|
||||
curl -f https://punktfri.i80.dk/health || echo "Service not yet available"
|
||||
|
||||
- name: Notify deployment status
|
||||
run: |
|
||||
echo "Deployment completed!"
|
||||
echo "Service: https://punktfri.i80.dk"
|
||||
echo "Health: https://punktfri.i80.dk/health"
|
||||
Reference in New Issue
Block a user