Use Kaniko for K8S native build
Some checks failed
Build with Kaniko / build (push) Failing after 1m15s

This commit is contained in:
2025-11-19 16:15:49 +08:00
parent ecdd3c9847
commit 836a091eb8
2 changed files with 57 additions and 57 deletions

View File

@@ -0,0 +1,57 @@
name: Build with Kaniko
on:
push:
branches:
- main
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Build Backend with Kaniko
uses: docker://gcr.io/kaniko-project/executor:latest
with:
args: >
--context=dir://./dashboard-backend
--dockerfile=./dashboard-backend/Dockerfile
--destination=cloudforge-dashboard-backend:${{ github.sha }}
--destination=cloudforge-dashboard-backend:latest
--no-push
--tar-path=/workspace/backend.tar
- name: Build Frontend with Kaniko
uses: docker://gcr.io/kaniko-project/executor:latest
with:
args: >
--context=dir://./dashboard-frontend
--dockerfile=./dashboard-frontend/Dockerfile
--destination=cloudforge-dashboard-frontend:${{ github.sha }}
--destination=cloudforge-dashboard-frontend:latest
--no-push
--tar-path=/workspace/frontend.tar
- name: Load images to containerd
run: |
# Import 到 K3S
ctr -n k8s.io images import /workspace/backend.tar
ctr -n k8s.io images import /workspace/frontend.tar
- name: Deploy with kubectl
run: |
kubectl set image deployment/dashboard-backend \
backend=cloudforge-dashboard-backend:${{ github.sha }} \
-n cloudforge || echo "Deployment not found, will create"
kubectl set image deployment/dashboard-frontend \
frontend=cloudforge-dashboard-frontend:${{ github.sha }} \
-n cloudforge || echo "Deployment not found, will create"
- name: Verify
run: |
kubectl rollout status deployment/dashboard-backend -n cloudforge -t 300s
kubectl rollout status deployment/dashboard-frontend -n cloudforge -t 300s