fix docker-build: use kaniko
This commit is contained in:
parent
b597da9e0f
commit
989006f6c9
1 changed files with 11 additions and 24 deletions
|
@ -5,8 +5,6 @@ variables:
|
|||
|
||||
dockerfile_lint:
|
||||
stage: .pre
|
||||
tags:
|
||||
- docker-runner
|
||||
image: hadolint/hadolint:latest-debian
|
||||
|
||||
allow_failure: true
|
||||
|
@ -18,33 +16,22 @@ dockerfile_lint:
|
|||
|
||||
.docker_build:
|
||||
stage: build
|
||||
tags:
|
||||
- docker-build
|
||||
variables:
|
||||
GIT_SUBMODULE_STRATEGY: recursive
|
||||
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:
|
||||
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_TAG" -f $DOCKERFILE_LOCATION/$DOCKERFILE_NAME $DOCKERFILE_LOCATION
|
||||
- docker push "$CI_REGISTRY_IMAGE:$CI_COMMIT_TAG"
|
||||
# Below is a nasty hack to also publish registry/xxxx/master:TAG
|
||||
# because else it's a shit show do deal with it on helm releases
|
||||
- docker tag "$CI_REGISTRY_IMAGE:$CI_COMMIT_TAG" "$CI_REGISTRY_IMAGE/master:$CI_COMMIT_TAG"
|
||||
- docker push "$CI_REGISTRY_IMAGE/master:$CI_COMMIT_TAG"
|
||||
- docker tag "$CI_REGISTRY_IMAGE:$CI_COMMIT_TAG" "$CI_REGISTRY_IMAGE/main:$CI_COMMIT_TAG"
|
||||
- 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"
|
||||
script: |
|
||||
/kaniko/executor \
|
||||
--force \
|
||||
--cache=true \
|
||||
--context "${CI_PROJECT_DIR}/${DOCKERFILE_LOCATION}" \
|
||||
--dockerfile "${CI_PROJECT_DIR}/${DOCKERFILE_LOCATION}/${DOCKERFILE_NAME}" \
|
||||
--destination "${CI_REGISTRY_IMAGE}/${CI_COMMIT_REF_NAME}:${CI_COMMIT_SHORT_SHA}"
|
||||
--destination "${CI_REGISTRY_IMAGE}/${CI_COMMIT_REF_NAME}:latest"
|
||||
except:
|
||||
- tags
|
||||
|
||||
|
|
Loading…
Reference in a new issue