Last active
January 30, 2025 10:53
-
-
Save tanmay-bhat/6bc6d6034644ef010d841ea8373a41d6 to your computer and use it in GitHub Desktop.
Using Kaniko to build and push images through Gitlab-CI to ECR
This file contains hidden or 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
#base image in which all stages are executed | |
image: alpine | |
# Ordered stages of the CI pipeline | |
stages: | |
- build_and_push | |
build and push docker image: | |
stage: build_and_push | |
only: | |
variables: | |
- $CI_COMMIT_TAG =~ /^v[0-9]+\.[0-9]+\.[0-9]+$/ | |
variables: | |
AWS_DEFAULT_REGION: REGION_NAME | |
CI_REGISTRY_IMAGE: YOUR_ACCOUNT_ID.dkr.ecr.REGION_NAME.amazonaws.com/REPO_NAME | |
image: | |
name: gcr.io/kaniko-project/executor:debug | |
entrypoint: [""] | |
script: | |
- mkdir -p /kaniko/.docker | |
- echo "{\"credsStore\":\"ecr-login\"}" > /kaniko/.docker/config.json | |
- >- | |
/kaniko/executor | |
--context "${CI_PROJECT_DIR}" | |
--dockerfile "${CI_PROJECT_DIR}/Dockerfile" | |
--destination "${CI_REGISTRY_IMAGE}:${CI_COMMIT_TAG}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment