.gitlab-ci.yml 902 Bytes
Newer Older
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
35
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