fix: use crane for OCI-compatible push to Zot
Some checks failed
Build and Push to Zot / build-and-push (push) Failing after 15m1s
Some checks failed
Build and Push to Zot / build-and-push (push) Failing after 15m1s
This commit is contained in:
@@ -13,7 +13,7 @@ jobs:
|
|||||||
build-and-push:
|
build-and-push:
|
||||||
runs-on: k3s-home
|
runs-on: k3s-home
|
||||||
steps:
|
steps:
|
||||||
- name: Create Kaniko Job
|
- name: Create Build Job
|
||||||
run: |
|
run: |
|
||||||
JOB_NAME="kaniko-jovies-$(echo $GITHUB_SHA | cut -c1-7)"
|
JOB_NAME="kaniko-jovies-$(echo $GITHUB_SHA | cut -c1-7)"
|
||||||
echo "Creating Kaniko Job: $JOB_NAME"
|
echo "Creating Kaniko Job: $JOB_NAME"
|
||||||
@@ -25,44 +25,66 @@ jobs:
|
|||||||
name: $JOB_NAME
|
name: $JOB_NAME
|
||||||
namespace: gitea
|
namespace: gitea
|
||||||
spec:
|
spec:
|
||||||
ttlSecondsAfterFinished: 300
|
ttlSecondsAfterFinished: 600
|
||||||
backoffLimit: 0
|
backoffLimit: 0
|
||||||
template:
|
template:
|
||||||
spec:
|
spec:
|
||||||
containers:
|
initContainers:
|
||||||
- name: kaniko
|
- name: kaniko
|
||||||
image: gcr.io/kaniko-project/executor:latest
|
image: gcr.io/kaniko-project/executor:latest
|
||||||
args:
|
args:
|
||||||
- "--context=git://github0213.com/Mayne0213/jovies.git#refs/heads/main"
|
- "--context=git://github0213.com/Mayne0213/jovies.git#refs/heads/main"
|
||||||
- "--context-sub-path=nextjs"
|
- "--context-sub-path=nextjs"
|
||||||
- "--dockerfile=Dockerfile"
|
- "--dockerfile=Dockerfile"
|
||||||
- "--destination=${REGISTRY}/${IMAGE_NAME}:latest"
|
- "--no-push"
|
||||||
- "--destination=${REGISTRY}/${IMAGE_NAME}:${GITHUB_SHA}"
|
- "--tar-path=/workspace/image.tar"
|
||||||
volumeMounts:
|
volumeMounts:
|
||||||
- name: docker-config
|
- name: workspace
|
||||||
mountPath: /kaniko/.docker
|
mountPath: /workspace
|
||||||
|
containers:
|
||||||
|
- name: crane
|
||||||
|
image: gcr.io/go-containerregistry/crane:latest
|
||||||
|
command: ["/bin/sh", "-c"]
|
||||||
|
args:
|
||||||
|
- |
|
||||||
|
echo "Pushing image to ${REGISTRY}/${IMAGE_NAME}..."
|
||||||
|
crane auth login ${REGISTRY} -u \$(cat /secrets/username) -p \$(cat /secrets/password)
|
||||||
|
crane push /workspace/image.tar ${REGISTRY}/${IMAGE_NAME}:latest
|
||||||
|
crane push /workspace/image.tar ${REGISTRY}/${IMAGE_NAME}:${GITHUB_SHA}
|
||||||
|
echo "Done!"
|
||||||
|
env:
|
||||||
|
- name: REGISTRY
|
||||||
|
value: "${REGISTRY}"
|
||||||
|
- name: IMAGE_NAME
|
||||||
|
value: "${IMAGE_NAME}"
|
||||||
|
- name: GITHUB_SHA
|
||||||
|
value: "${GITHUB_SHA}"
|
||||||
|
volumeMounts:
|
||||||
|
- name: workspace
|
||||||
|
mountPath: /workspace
|
||||||
|
- name: zot-creds
|
||||||
|
mountPath: /secrets
|
||||||
volumes:
|
volumes:
|
||||||
- name: docker-config
|
- name: workspace
|
||||||
|
emptyDir: {}
|
||||||
|
- name: zot-creds
|
||||||
secret:
|
secret:
|
||||||
secretName: zot-registry-credentials
|
secretName: zot-registry-credentials-plain
|
||||||
items:
|
|
||||||
- key: .dockerconfigjson
|
|
||||||
path: config.json
|
|
||||||
restartPolicy: Never
|
restartPolicy: Never
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
- name: Wait for Kaniko Job
|
- name: Wait for Build Job
|
||||||
run: |
|
run: |
|
||||||
JOB_NAME="kaniko-jovies-$(echo $GITHUB_SHA | cut -c1-7)"
|
JOB_NAME="kaniko-jovies-$(echo $GITHUB_SHA | cut -c1-7)"
|
||||||
echo "Waiting for Job: $JOB_NAME"
|
echo "Waiting for Job: $JOB_NAME"
|
||||||
|
|
||||||
if ! kubectl wait --for=condition=complete job/$JOB_NAME -n gitea --timeout=600s; then
|
if ! kubectl wait --for=condition=complete job/$JOB_NAME -n gitea --timeout=900s; then
|
||||||
echo "Job failed. Logs:"
|
echo "Job failed. Logs:"
|
||||||
kubectl logs job/$JOB_NAME -n gitea
|
kubectl logs job/$JOB_NAME -n gitea --all-containers
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "Build completed successfully!"
|
echo "Build and push completed successfully!"
|
||||||
|
|
||||||
- name: Cleanup
|
- name: Cleanup
|
||||||
if: always()
|
if: always()
|
||||||
|
|||||||
Reference in New Issue
Block a user