templates/tpl/docker-build.yml

45 lines
1.2 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
except:
- tags
- schedules
.docker_build:
stage: build
image:
name: gcr.io/kaniko-project/executor:debug
entrypoint: [""]
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-commit:
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
- schedules