image: docker:19.03.6 stages: - build variables: DOCKER_DRIVER: overlay2 DOCKER_TLS_CERTDIR: "" services: - name: docker:19.03.6-dind command: ["--mtu=1458"] build and publish the image: stage: build before_script: - docker info - echo " --------------------------------- " script: # Login into gitlab registry. If that fails, the script should exit - docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY # Get the previous version, so that we could reuse the cache - 'docker pull $CI_REGISTRY_IMAGE:latest || true' # Build the new version, assign new tag and `latest` tag - docker build --cache-from $CI_REGISTRY_IMAGE:latest . - docker build -t $CI_REGISTRY_IMAGE:$(CI_COMMIT_TAG) . # Push the newly built version to the registry - docker push $CI_REGISTRY_IMAGE tags: - privileged rules: - if: $CI_COMMIT_TAG