You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
63 lines
2.2 KiB
YAML
63 lines
2.2 KiB
YAML
---
|
|
|
|
# A Gitlab CI job template for building docker images using kaniko.
|
|
#
|
|
# Required environment variables:
|
|
# - KANIKO_BUILD_IMAGENAME: Build/target image name.
|
|
# Images will be named like
|
|
# `open.greenhost.net:4567/GROUP/PROJECT/KANIKO_BUILD_IMAGENAME:TAG`
|
|
# , where TAG is the CI_COMMIT_REF_SLUG, and also the CI_COMMIT_TAG if set.
|
|
#
|
|
# Optional environment variables:
|
|
# - KANIKO_CONTEXT: The subdir which holds the Dockerfile, leave unset if
|
|
# the Dockerfile is located at root level of the project.
|
|
.kaniko_build:
|
|
stage: build
|
|
image:
|
|
# We need a shell to provide the registry credentials, so we need to use the
|
|
# kaniko debug image (https://github.com/GoogleContainerTools/kaniko#debug-image)
|
|
name: gcr.io/kaniko-project/executor:debug
|
|
entrypoint: [""]
|
|
script:
|
|
- echo "{\"auths\":{\"$CI_REGISTRY\":{\"username\":\"$CI_REGISTRY_USER\",\"password\":\"$CI_REGISTRY_PASSWORD\"}}}" > /kaniko/.docker/config.json
|
|
- if [ -n "${CI_COMMIT_TAG}" ]; then export KANIKO_BUILD_TAGNAME="${CI_COMMIT_TAG}"; else export KANIKO_BUILD_TAGNAME="${CI_COMMIT_REF_SLUG}"; fi
|
|
- /kaniko/executor --cache=true --context ${CI_PROJECT_DIR}/${KANIKO_CONTEXT:-.} --dockerfile ${CI_PROJECT_DIR}/${KANIKO_CONTEXT:-.}/Dockerfile --destination ${CI_REGISTRY_IMAGE}/${KANIKO_BUILD_IMAGENAME}:${KANIKO_BUILD_TAGNAME}
|
|
|
|
stages:
|
|
- build
|
|
|
|
default:
|
|
image: "${CI_REGISTRY_IMAGE}/${KANIKO_BUILD_IMAGENAME}:${CI_COMMIT_REF_SLUG}"
|
|
|
|
build-wp-cli:
|
|
stage: build
|
|
variables:
|
|
KANIKO_BUILD_IMAGENAME: wordpress-cli-ansible
|
|
KANIKO_CONTEXT: wp-cli-docker
|
|
extends: .kaniko_build
|
|
# Run this job if files have changed that are used when building the docker
|
|
# image, or when the commit is a tag.
|
|
rules:
|
|
- changes:
|
|
- wp-cli-docker/**/**/*
|
|
- .gitlab-ci.yml
|
|
when: on_success
|
|
- if: '$CI_COMMIT_TAG'
|
|
when: on_success
|
|
|
|
build-wp:
|
|
stage: build
|
|
variables:
|
|
KANIKO_BUILD_IMAGENAME: wordpress
|
|
KANIKO_CONTEXT: wp-docker
|
|
extends: .kaniko_build
|
|
# Run this job if files have changed that are used when building the docker
|
|
# image, or when the commit is a tag.
|
|
rules:
|
|
- changes:
|
|
- wp-docker/**
|
|
- .gitlab-ci.yml
|
|
when: on_success
|
|
- if: '$CI_COMMIT_TAG'
|
|
when: on_success
|