ci: switch to Docker image build and kubectl rollout
Some checks failed
Build and Deploy / deploy (push) Failing after 30s

This commit is contained in:
djg 2026-09-21 22:25:39 +00:00
parent 09c3037d62
commit a3193fb40d
3 changed files with 56 additions and 6 deletions

View file

@ -10,10 +10,21 @@ jobs:
- name: Checkout - name: Checkout
uses: actions/checkout@v4 uses: actions/checkout@v4
- name: Build site - name: Build image
run: python3 build.py
- name: Deploy to nginx docroot
run: | run: |
rsync -av --delete site/ /home/opc/zai-home-base/sites/bestdadjokes/ docker build \
echo "Deployed at $(date)" -t git.ch4t.buzz/djg/bestdadjokes:${{ github.sha }} \
-t git.ch4t.buzz/djg/bestdadjokes:latest \
.
- name: Push to registry
run: |
docker push git.ch4t.buzz/djg/bestdadjokes:${{ github.sha }}
docker push git.ch4t.buzz/djg/bestdadjokes:latest
- name: Roll out to k8s
run: |
kubectl set image deployment/static-bdj \
nginx=git.ch4t.buzz/djg/bestdadjokes:${{ github.sha }} \
-n default
kubectl rollout status deployment/static-bdj -n default --timeout=120s

11
Dockerfile Normal file
View file

@ -0,0 +1,11 @@
# Build: run build.py to generate the static site
FROM python:3.11-slim AS builder
WORKDIR /app
COPY . .
RUN python3 build.py
# Serve: bake the built site into nginx:alpine
FROM nginx:alpine
COPY --from=builder /app/site/ /usr/share/nginx/html/
COPY nginx.conf /etc/nginx/nginx.conf
EXPOSE 80

28
nginx.conf Normal file
View file

@ -0,0 +1,28 @@
worker_processes 1;
error_log /dev/stderr warn;
pid /tmp/nginx.pid;
events { worker_connections 1024; }
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
access_log /dev/stdout;
sendfile on;
gzip on;
gzip_types text/plain text/css application/javascript application/json application/xml image/svg+xml;
gzip_min_length 1024;
server {
listen 80;
root /usr/share/nginx/html;
index index.html;
error_page 404 /404.html;
add_header X-Content-Type-Options nosniff always;
add_header Referrer-Policy strict-origin-when-cross-origin always;
location ~* \.(css|js|svg|png|jpg|ico|woff2?)$ {
expires 7d;
add_header Cache-Control "public";
}
location / {
try_files $uri $uri/ $uri/index.html =404;
}
}
}