Add Gitea Actions workflow to build and push images
Build and push CoqDecks / build (push) Has been cancelled
Build and push CoqDecks / build (push) Has been cancelled
Builds coqdecks-server and coqdecks-client Docker images via a BuildKit Kubernetes job and pushes them to the in-cluster registry. Uses per-image registry layer caches to speed up incremental builds. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,97 @@
|
||||
name: Build and push CoqDecks
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: native
|
||||
timeout-minutes: 120
|
||||
|
||||
steps:
|
||||
- name: Build and push CoqDecks images with BuildKit
|
||||
run: |
|
||||
kubectl -n ci delete job coqdecks-buildkit --ignore-not-found=true --wait=true
|
||||
|
||||
BRANCH=${GITEA_REF_NAME:-${GITHUB_REF_NAME:-main}}
|
||||
cat <<'EOF' | sed "s|__BRANCH__|${BRANCH}|g" | kubectl apply -f -
|
||||
apiVersion: batch/v1
|
||||
kind: Job
|
||||
metadata:
|
||||
name: coqdecks-buildkit
|
||||
namespace: ci
|
||||
spec:
|
||||
backoffLimit: 0
|
||||
template:
|
||||
spec:
|
||||
restartPolicy: Never
|
||||
initContainers:
|
||||
- name: prepare
|
||||
image: alpine/git:latest
|
||||
command: ["sh", "-c"]
|
||||
args:
|
||||
- |
|
||||
set -eux
|
||||
git clone --depth 1 --branch __BRANCH__ https://git.alocoq.fr/alois/CoqDecks.git /workspace/repo
|
||||
volumeMounts:
|
||||
- name: workspace
|
||||
mountPath: /workspace
|
||||
|
||||
containers:
|
||||
- name: buildkit
|
||||
image: moby/buildkit:latest
|
||||
securityContext:
|
||||
privileged: true
|
||||
command: ["sh", "-c"]
|
||||
args:
|
||||
- |
|
||||
set -eux
|
||||
|
||||
REG=registry.git.svc.cluster.local:5000
|
||||
|
||||
mkdir -p /etc/buildkit
|
||||
printf '[registry."%s"]\n http = true\n insecure = true\n' "$REG" > /etc/buildkit/buildkitd.toml
|
||||
|
||||
# Build server image
|
||||
buildctl-daemonless.sh build \
|
||||
--frontend=dockerfile.v0 \
|
||||
--local context=/workspace/repo/server \
|
||||
--local dockerfile=/workspace/repo/server \
|
||||
--import-cache type=registry,ref=$REG/coqdecks-cache:server \
|
||||
--export-cache type=registry,ref=$REG/coqdecks-cache:server,mode=max \
|
||||
--output type=image,name=$REG/coqdecks-server:latest,push=true,registry.insecure=true
|
||||
|
||||
# Build client image
|
||||
buildctl-daemonless.sh build \
|
||||
--frontend=dockerfile.v0 \
|
||||
--local context=/workspace/repo/client \
|
||||
--local dockerfile=/workspace/repo/client \
|
||||
--import-cache type=registry,ref=$REG/coqdecks-cache:client \
|
||||
--export-cache type=registry,ref=$REG/coqdecks-cache:client,mode=max \
|
||||
--output type=image,name=$REG/coqdecks-client:latest,push=true,registry.insecure=true
|
||||
volumeMounts:
|
||||
- name: workspace
|
||||
mountPath: /workspace
|
||||
|
||||
volumes:
|
||||
- name: workspace
|
||||
emptyDir: {}
|
||||
EOF
|
||||
|
||||
- name: Wait for build
|
||||
run: |
|
||||
kubectl -n ci wait --for=condition=complete job/coqdecks-buildkit --timeout=7200s
|
||||
|
||||
- name: Show build logs
|
||||
if: always()
|
||||
run: |
|
||||
kubectl -n ci logs job/coqdecks-buildkit -c prepare || true
|
||||
kubectl -n ci logs job/coqdecks-buildkit -c buildkit || true
|
||||
|
||||
- name: Cleanup
|
||||
if: always()
|
||||
run: |
|
||||
kubectl -n ci delete job coqdecks-buildkit --ignore-not-found=true --wait=true
|
||||
Reference in New Issue
Block a user