Spaces:
Build error
Build error
variables: | |
GIT_STRATEGY: fetch | |
GIT_SSL_NO_VERIFY: "true" | |
GIT_LFS_SKIP_SMUDGE: 1 | |
DOCKER_BUILDKIT: 1 | |
stages: | |
- build | |
image_build: | |
stage: build | |
image: docker:stable | |
before_script: | |
- docker login -u gitlab-ci-token -p $CI_JOB_TOKEN http://$CI_REGISTRY | |
script: | | |
CI_COMMIT_SHA_7=$(echo $CI_COMMIT_SHA | cut -c1-7) | |
DATE=$(date +%Y-%m-%d) | |
docker build --tag $CI_REGISTRY_IMAGE/$CI_COMMIT_BRANCH:latest \ | |
--tag $CI_REGISTRY_IMAGE/$CI_COMMIT_BRANCH:$CI_COMMIT_SHA_7 \ | |
--tag $CI_REGISTRY_IMAGE/$CI_COMMIT_BRANCH:$DATE \ | |
-f Dockerfile . | |
docker push $CI_REGISTRY_IMAGE/$CI_COMMIT_BRANCH:latest | |
docker push $CI_REGISTRY_IMAGE/$CI_COMMIT_BRANCH:$CI_COMMIT_SHA_7 | |
docker push $CI_REGISTRY_IMAGE/$CI_COMMIT_BRANCH:$DATE | |
# Run only when Dockerfile has changed | |
rules: | |
- if: $CI_PIPELINE_SOURCE == "push" | |
changes: | |
- Dockerfile | |
# Set to `on_success` to automatically rebuild | |
# Set to `manual` to trigger the build manually using Gitlab UI | |
when: on_success | |
allow_failure: true | |