fix docker-build: use kaniko

This commit is contained in:
Frank Villaro-Dixon 2022-02-27 20:15:14 +01:00
parent b597da9e0f
commit 989006f6c9

View file

@ -5,8 +5,6 @@ variables:
dockerfile_lint: dockerfile_lint:
stage: .pre stage: .pre
tags:
- docker-runner
image: hadolint/hadolint:latest-debian image: hadolint/hadolint:latest-debian
allow_failure: true allow_failure: true
@ -18,33 +16,22 @@ dockerfile_lint:
.docker_build: .docker_build:
stage: build stage: build
tags:
- docker-build
variables: variables:
GIT_SUBMODULE_STRATEGY: recursive GIT_SUBMODULE_STRATEGY: recursive
before_script: before_script:
- docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY - mkdir -p /kaniko/.docker
- echo "{\"auths\":{\"${CI_REGISTRY}\":{\"auth\":\"$(printf "%s:%s" "${CI_REGISTRY_USER}" "${CI_REGISTRY_PASSWORD}" | base64 | tr -d '\n')\"}}}" > /kaniko/.docker/config.json
docker-build-tags: docker-build-tags:
extends: .docker_build extends: .docker_build
script: script: |
- docker build --pull --build-arg CACHEBUST=$(date +%s) --build-arg CI_COMMIT_SHORT_SHA=$CI_COMMIT_SHORT_SHA -t "$CI_REGISTRY_IMAGE:$CI_COMMIT_TAG" -f $DOCKERFILE_LOCATION/$DOCKERFILE_NAME $DOCKERFILE_LOCATION /kaniko/executor \
- docker push "$CI_REGISTRY_IMAGE:$CI_COMMIT_TAG" --force \
# Below is a nasty hack to also publish registry/xxxx/master:TAG --cache=true \
# because else it's a shit show do deal with it on helm releases --context "${CI_PROJECT_DIR}/${DOCKERFILE_LOCATION}" \
- docker tag "$CI_REGISTRY_IMAGE:$CI_COMMIT_TAG" "$CI_REGISTRY_IMAGE/master:$CI_COMMIT_TAG" --dockerfile "${CI_PROJECT_DIR}/${DOCKERFILE_LOCATION}/${DOCKERFILE_NAME}" \
- docker push "$CI_REGISTRY_IMAGE/master:$CI_COMMIT_TAG" --destination "${CI_REGISTRY_IMAGE}/${CI_COMMIT_REF_NAME}:${CI_COMMIT_SHORT_SHA}"
- docker tag "$CI_REGISTRY_IMAGE:$CI_COMMIT_TAG" "$CI_REGISTRY_IMAGE/main:$CI_COMMIT_TAG" --destination "${CI_REGISTRY_IMAGE}/${CI_COMMIT_REF_NAME}:latest"
- docker push "$CI_REGISTRY_IMAGE/main:$CI_COMMIT_TAG"
only:
- tags
docker-build:
extends: .docker_build
script:
- docker build --pull --build-arg CACHEBUST=$(date +%s) --build-arg CI_COMMIT_SHORT_SHA=$CI_COMMIT_SHORT_SHA -t "$CI_REGISTRY_IMAGE/$CI_COMMIT_REF_NAME:$CI_COMMIT_SHORT_SHA" -f $DOCKERFILE_LOCATION/$DOCKERFILE_NAME $DOCKERFILE_LOCATION
- docker push "$CI_REGISTRY_IMAGE/$CI_COMMIT_REF_NAME:$CI_COMMIT_SHORT_SHA"
- docker tag $CI_REGISTRY_IMAGE/$CI_COMMIT_REF_NAME:$CI_COMMIT_SHORT_SHA $CI_REGISTRY_IMAGE/$CI_COMMIT_REF_NAME:latest
- docker push "$CI_REGISTRY_IMAGE/$CI_COMMIT_REF_NAME:latest"
except: except:
- tags - tags