Spaces:
Build error
Build error
File size: 1,101 Bytes
daf0288 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
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
|