templates/tpl/docker-build.yml
2022-02-27 20:15:14 +01:00

37 lines
1 KiB
YAML

variables:
DOCKERFILE_LOCATION: '.'
DOCKERFILE_NAME: 'Dockerfile'
dockerfile_lint:
stage: .pre
image: hadolint/hadolint:latest-debian
allow_failure: true
before_script:
- 'cd $DOCKERFILE_LOCATION'
script:
- hadolint --ignore DL3008 --ignore DL3059 $DOCKERFILE_NAME
.docker_build:
stage: build
variables:
GIT_SUBMODULE_STRATEGY: recursive
before_script:
- 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: |
/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