75 lines
2.4 KiB
YAML
75 lines
2.4 KiB
YAML
stages:
|
|
- build
|
|
|
|
.docker-build: &docker-build
|
|
stage: build
|
|
image:
|
|
name: gcr.io/kaniko-project/executor:debug
|
|
entrypoint: [ "" ]
|
|
needs: [ ]
|
|
variables:
|
|
GIT_DEPTH: "1"
|
|
TZ: "UTC"
|
|
before_script:
|
|
- mkdir -p /kaniko/.docker
|
|
- echo "{\"auths\":{\"$CI_REGISTRY\":{\"username\":\"gitlab-ci-token\",\"password\":\"$CI_JOB_TOKEN\"}}}" > /kaniko/.docker/config.json
|
|
script: |
|
|
set -eu
|
|
|
|
source "common.config"
|
|
source "$BUILD_TYPE.config"
|
|
|
|
export JOB_TIMESTAMP="$(date -D '%Y-%m-%dT%H:%M:%S%Z' -d "$CI_JOB_STARTED_AT" +'%Y%m%d-%H%M')"
|
|
|
|
echo "Building image with"
|
|
echo " -> haproxy version: $HAPROXY_VER"
|
|
echo " -> debian codename: $DEBIAN_CODENAME"
|
|
echo " -> git commit hash: $CI_COMMIT_SHORT_SHA"
|
|
echo " -> build timestamp: $JOB_TIMESTAMP"
|
|
|
|
export IMAGE_TAG_UNIQUE="$HAPROXY_VER-$DEBIAN_CODENAME-$CI_COMMIT_SHORT_SHA-$JOB_TIMESTAMP"
|
|
export IMAGE_TAG_ROLLING_COMMIT="git-$CI_COMMIT_SHORT_SHA"
|
|
export IMAGE_TAG_ROLLING_GITREF="$CI_COMMIT_REF_SLUG"
|
|
|
|
export IMAGE_TAG_VERSIONS="$HAPROXY_VER-$DEBIAN_CODENAME"
|
|
if [ "$CI_COMMIT_REF_NAME" != "$CI_DEFAULT_BRANCH" ]; then
|
|
export IMAGE_TAG_VERSIONS="branch-$CI_COMMIT_REF_SLUG-$IMAGE_TAG_VERSIONS"
|
|
echo "Git reference $CI_COMMIT_REF_NAME is not the default branch. Rewriting git rolling tag as $IMAGE_TAG_VERSIONS"
|
|
fi
|
|
|
|
export IMAGE_PATH="$CI_REGISTRY_IMAGE/$BUILD_TYPE"
|
|
|
|
echo "***"
|
|
echo "Will build and push image as:"
|
|
echo "- $IMAGE_PATH:$IMAGE_TAG_UNIQUE"
|
|
echo "- $IMAGE_PATH:$IMAGE_TAG_ROLLING_COMMIT"
|
|
echo "- $IMAGE_PATH:$IMAGE_TAG_ROLLING_GITREF"
|
|
echo "- $IMAGE_PATH:$IMAGE_TAG_VERSIONS"
|
|
echo "***"
|
|
|
|
(
|
|
set -x;
|
|
/kaniko/executor \
|
|
--single-snapshot \
|
|
--context . \
|
|
--dockerfile Dockerfile \
|
|
--build-arg "DEBIAN_CODENAME=$DEBIAN_CODENAME" \
|
|
--build-arg "QUICTLS_SOURCE=$QUICTLS_SOURCE" \
|
|
--build-arg "HAPROXY_SOURCE_REPO=$HAPROXY_SOURCE_REPO" \
|
|
--build-arg "HAPROXY_SOURCE_BRANCH=$HAPROXY_SOURCE_BRANCH" \
|
|
--destination "$IMAGE_PATH:$IMAGE_TAG_UNIQUE" \
|
|
--destination "$IMAGE_PATH:$IMAGE_TAG_ROLLING_COMMIT" \
|
|
--destination "$IMAGE_PATH:$IMAGE_TAG_ROLLING_GITREF" \
|
|
--destination "$IMAGE_PATH:$IMAGE_TAG_ROLLING_DEB"
|
|
)
|
|
|
|
mainline:
|
|
<<: *docker-build
|
|
variables:
|
|
BUILD_TYPE: mainline
|
|
|
|
nightly:
|
|
<<: *docker-build
|
|
variables:
|
|
BUILD_TYPE: nightly
|