Eric Engestrom | 329f5cd | 2019-01-20 11:21:45 +0000 | [diff] [blame^] | 1 | # This is the tag of the docker image used for the build jobs. If the |
| 2 | # image doesn't exist yet, the containers-build stage generates it. |
| 3 | # |
| 4 | # In order to generate a new image, one should generally change the tag. |
| 5 | # While removing the image from the registry would also work, that's not |
| 6 | # recommended except for ephemeral images during development: Replacing |
| 7 | # an image after a significant amount of time might pull in newer |
| 8 | # versions of gcc/clang or other packages, which might break the build |
| 9 | # with older commits using the same tag. |
| 10 | # |
| 11 | # After merging a change resulting in generating a new image to the |
| 12 | # main repository, it's recommended to remove the image from the source |
| 13 | # repository's container registry, so that the image from the main |
| 14 | # repository's registry will be used there as well. |
| 15 | # |
| 16 | # The format of the tag is "%Y-%m-%d-${counter}" where ${counter} stays |
| 17 | # at "01" unless you have multiple updates on the same day :) |
| 18 | variables: |
| 19 | UBUNTU_TAG: 2019-01-31-01 |
| 20 | UBUNTU_IMAGE: "$CI_REGISTRY/$CI_PROJECT_PATH/ubuntu:$UBUNTU_TAG" |
| 21 | |
| 22 | |
| 23 | stages: |
| 24 | - containers-build |
| 25 | |
| 26 | |
| 27 | # CONTAINERS |
| 28 | |
| 29 | containers:ubuntu: |
| 30 | stage: containers-build |
| 31 | image: docker:stable |
| 32 | services: |
| 33 | - docker:dind |
| 34 | variables: |
| 35 | DOCKER_HOST: tcp://docker:2375 |
| 36 | DOCKER_DRIVER: overlay2 |
| 37 | script: |
| 38 | # Enable experimental features such as `docker manifest inspect` |
| 39 | - mkdir -p ~/.docker |
| 40 | - "echo '{\"experimental\": \"enabled\"}' > ~/.docker/config.json" |
| 41 | - docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY |
| 42 | # Check if the image (with the specific tag) already exists |
| 43 | - docker manifest inspect $UBUNTU_IMAGE && exit || true |
| 44 | - docker build -t $UBUNTU_IMAGE -f .gitlab-ci/Dockerfile.ubuntu . |
| 45 | - docker push $UBUNTU_IMAGE |
| 46 | only: |
| 47 | changes: |
| 48 | - .gitlab-ci.yml |
| 49 | - .gitlab-ci/Dockerfile.ubuntu |