ci: switch to Docker image build and kubectl rollout
This commit is contained in:
parent
46a1e418a5
commit
43edfa44b8
3 changed files with 54 additions and 6 deletions
|
|
@ -10,10 +10,21 @@ jobs:
|
|||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Build site
|
||||
run: python3 build.py
|
||||
|
||||
- name: Deploy to nginx docroot
|
||||
- name: Build image
|
||||
run: |
|
||||
rsync -av --delete site/ /home/opc/zai-home-base/sites/helpme-tips/
|
||||
echo "Deployed at $(date)"
|
||||
docker build \
|
||||
-t git.ch4t.buzz/djg/helpme-tips:${{ github.sha }} \
|
||||
-t git.ch4t.buzz/djg/helpme-tips:latest \
|
||||
.
|
||||
|
||||
- name: Push to registry
|
||||
run: |
|
||||
docker push git.ch4t.buzz/djg/helpme-tips:${{ github.sha }}
|
||||
docker push git.ch4t.buzz/djg/helpme-tips:latest
|
||||
|
||||
- name: Roll out to k8s
|
||||
run: |
|
||||
kubectl set image deployment/static-hts \
|
||||
nginx=git.ch4t.buzz/djg/helpme-tips:${{ github.sha }} \
|
||||
-n default
|
||||
kubectl rollout status deployment/static-hts -n default --timeout=120s
|
||||
|
|
|
|||
9
Dockerfile
Normal file
9
Dockerfile
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
FROM python:3.11-slim AS builder
|
||||
WORKDIR /app
|
||||
COPY . .
|
||||
RUN python3 build.py
|
||||
|
||||
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
28
nginx.conf
Normal 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue