-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy path.gitlab-ci.yml
24 lines (23 loc) · 1.04 KB
/
.gitlab-ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
stages:
- build
# Based on https://gitlab.cern.ch/ci-tools/docker-image-builder
build_image:
stage: build
image:
name: gcr.io/kaniko-project/executor:debug
entrypoint: [""]
script:
# Get the image name and version to be built
- IMAGE_NAME=$(echo $CI_COMMIT_TAG | cut -d / -f 1)
- IMAGE_VERSION=$(echo $CI_COMMIT_TAG | cut -d / -f 2)
- IMAGE_DESTINATION=$CI_REGISTRY_IMAGE/$IMAGE_NAME:$IMAGE_VERSION
# Create kaniko directory
- mkdir -p /kaniko/.docker
# Prepare Kaniko configuration file
- echo "{\"auths\":{\"$CI_REGISTRY\":{\"username\":\"$CI_REGISTRY_USER\",\"password\":\"$CI_REGISTRY_PASSWORD\"}}}" > /kaniko/.docker/config.json
# Build and push the image from the specified Dockerfile
- /kaniko/executor --context $CI_PROJECT_DIR/$IMAGE_NAME --dockerfile $CI_PROJECT_DIR/$IMAGE_NAME/Dockerfile --build-arg BUILD_TAG=$IMAGE_VERSION --destination $IMAGE_DESTINATION
# Print the full registry path of the pushed image
- echo "Image pushed successfully to ${IMAGE_DESTINATION}"
only:
- tags