Use Kaniko for K8S native build
Some checks failed
Build with Kaniko / build (push) Failing after 1m15s
Some checks failed
Build with Kaniko / build (push) Failing after 1m15s
This commit is contained in:
57
.gitea/workflows/kaniko-build.yml
Normal file
57
.gitea/workflows/kaniko-build.yml
Normal 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
|
||||
Reference in New Issue
Block a user