Skip to content

Instantly share code, notes, and snippets.

@tanmay-bhat
Last active January 30, 2025 10:53
Show Gist options
  • Save tanmay-bhat/6bc6d6034644ef010d841ea8373a41d6 to your computer and use it in GitHub Desktop.
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
#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