Created
June 26, 2023 12:15
-
-
Save mhutter/f0067275c47eab2ce5ee4045049fca4d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
stages: | |
- build | |
build-image: | |
stage: build | |
image: | |
# Use Google's Kaniko builder | |
name: gcr.io/kaniko-project/executor:debug | |
entrypoint: [""] | |
variables: | |
# Determine the image name based on the repository n | |
IMAGE: "${CI_REGISTRY_IMAGE}:${CI_BUILD_REF_SLUG}" | |
before_script: | |
# Ensure Kaniko's docker config folder exists | |
- mkdir -p /kaniko/.docker | |
# Write registry credentials | |
- printf '{"auths":{"%s":{"username":"%s","password":"%s"}}}\n' "${IMAGE/:master/:latest}" "$CI_REGISTRY_USER" "$CI_REGISTRY_PASSWORD" > /kaniko/.docker/config.json | |
script: | |
# Build & push image; use VSHN's Dockerhub mirror to pull | |
- /kaniko/executor --context "$CI_PROJECT_DIR" --destination "${IMAGE/:master/:latest}" --registry-mirror dockerhub.vshn.net | |
after_script: | |
# Clean up registry credentials | |
- rm -f /kaniko/.docker/config.json |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment