[Mesa-dev] [PATCH v2 5/5] gitlab-ci: use branch/tag in base image names
Juan A. Suarez Romero
jasuarez at igalia.com
Wed Aug 29 10:12:38 UTC 2018
To avoid conflicts with the base images when building two different
branches or tags at the same time, let's use different base/llvm image
names.
This way if both branches require different dependencies each one will
use its own base/llvm images.
Signed-off-by: Juan A. Suarez Romero <jasuarez at igalia.com>
---
.gitlab-ci.yml | 12 +++++++-----
gitlab-ci/Rockerfile.base | 6 ++++--
gitlab-ci/Rockerfile.llvm | 9 ++++++---
gitlab-ci/Rockerfile.mesa | 15 ++++++++-------
4 files changed, 25 insertions(+), 17 deletions(-)
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index d66def2e7bb..0514d5d4ef8 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -39,17 +39,18 @@ after_script:
cache: {}
script:
- DOCKERFILE_SHA256=$(cat gitlab-ci/Rockerfile.base gitlab-ci/Rockerfile.llvm | sha256sum | cut -c-64)
- - IMAGE_DOCKERFILE_SHA256=$(./gitlab-ci/inspect-remote-image.sh gitlab-ci-token $CI_BUILD_TOKEN $CI_PROJECT_PATH "llvm-$LLVM" ".config.Labels[\"dockerfile.sha256\"]" || echo -n "<notfound>")
+ - IMAGE_TAG=$CI_COMMIT_REF_SLUG-llvm-$LLVM
+ - IMAGE_DOCKERFILE_SHA256=$(./gitlab-ci/inspect-remote-image.sh gitlab-ci-token $CI_BUILD_TOKEN $CI_PROJECT_PATH $IMAGE_TAG ".config.Labels[\"dockerfile.sha256\"]" || echo -n "<notfound>")
- if [ "$DOCKERFILE_SHA256" != "$IMAGE_DOCKERFILE_SHA256" ] || [ "$CI_PIPELINE_SOURCE" == "schedule" ] ; then FORCE_BUILD=true ; fi
- if [ "$FORCE_BUILD" ] ; then ../rocker build -f gitlab-ci/Rockerfile.llvm --var DOCKERFILE_SHA256=$DOCKERFILE_SHA256 --var LLVM=$LLVM ; fi
- - if [ "$FORCE_BUILD" ] ; then docker push $CI_REGISTRY_IMAGE:llvm-$LLVM ; fi
+ - if [ "$FORCE_BUILD" ] ; then docker push $CI_REGISTRY_IMAGE:$IMAGE_TAG ; fi
.build_mesa: &build_mesa
stage: mesa
except:
- schedules
script:
- - ../rocker build -f gitlab-ci/Rockerfile.mesa --var BUILD=$BUILD --var LLVM=$LLVM --var TAG=$CI_COMMIT_REF_SLUG .
+ - ../rocker build -f gitlab-ci/Rockerfile.mesa --var BUILD=$BUILD --var LLVM=$LLVM .
.build_tarball: &build_tarball
stage: tarball
@@ -65,10 +66,11 @@ base:
stage: base
script:
- DOCKERFILE_SHA256=$(cat gitlab-ci/Rockerfile.base | sha256sum | cut -c-64)
- - IMAGE_DOCKERFILE_SHA256=$(./gitlab-ci/inspect-remote-image.sh gitlab-ci-token $CI_BUILD_TOKEN $CI_PROJECT_PATH "base" ".config.Labels[\"dockerfile.sha256\"]" || echo -n "<notfound>")
+ - IMAGE_TAG=$CI_COMMIT_REF_SLUG-base
+ - IMAGE_DOCKERFILE_SHA256=$(./gitlab-ci/inspect-remote-image.sh gitlab-ci-token $CI_BUILD_TOKEN $CI_PROJECT_PATH $IMAGE_TAG ".config.Labels[\"dockerfile.sha256\"]" || echo -n "<notfound>")
- if [ "$DOCKERFILE_SHA256" != "$IMAGE_DOCKERFILE_SHA256" ] || [ "$CI_PIPELINE_SOURCE" == "schedule" ] ; then FORCE_BUILD=true ; fi
- if [ "$FORCE_BUILD" ] ; then ../rocker build -f gitlab-ci/Rockerfile.base --var DOCKERFILE_SHA256=$DOCKERFILE_SHA256 ; fi
- - if [ "$FORCE_BUILD" ] ; then docker push $CI_REGISTRY_IMAGE:base ; fi
+ - if [ "$FORCE_BUILD" ] ; then docker push $CI_REGISTRY_IMAGE:$IMAGE_TAG ; fi
llvm:3.3:
variables:
diff --git a/gitlab-ci/Rockerfile.base b/gitlab-ci/Rockerfile.base
index 2e14875ce5a..99fce905c47 100644
--- a/gitlab-ci/Rockerfile.base
+++ b/gitlab-ci/Rockerfile.base
@@ -7,12 +7,14 @@
# ~~~
#
# Environment variables that are used in the build:
-# - DOCKER_IMAGE: name of the final image to be tagged (default: mesa:base)
+# - CI_COMMIT_REF_SLUG: branch/tag name, escaped
+# - DOCKER_IMAGE: name of the final image to be tagged (default: mesa:esa:$CI-COMMIT_REF_SLUG-base)
# - MAKEFLAGS: flags to pass to make (e.g., "-j8")
# - CCACHE_DIR: ccache directory (e.g, ~/.ccache)
#
{{ $image := (or .Env.DOCKER_IMAGE "mesa") }}
+{{ $tag := (print (or .Env.CI_COMMIT_REF_SLUG "local") "-base") }}
FROM ubuntu:xenial
@@ -184,4 +186,4 @@ RUN wget https://wayland.freedesktop.org/releases/wayland-protocols-1.8.tar.xz
USER root
-TAG {{ $image }}:base
+TAG {{ $image }}:{{ $tag }}
diff --git a/gitlab-ci/Rockerfile.llvm b/gitlab-ci/Rockerfile.llvm
index cb2906d9a40..ae68a4a9885 100644
--- a/gitlab-ci/Rockerfile.llvm
+++ b/gitlab-ci/Rockerfile.llvm
@@ -8,7 +8,8 @@
# ~~~
#
# Environment variables that are used in the build:
-# - DOCKER_IMAGE: name of the final image to be tagged (default: mesa:$LLVM)
+# - CI_COMMIT_REF_SLUG: branch/tag name, escaped
+# - DOCKER_IMAGE: name of the final image to be tagged (default: mesa:$CI_COMMIT_REF_SLUG-$LLVM)
#
# NOTE: LLVM 3.3 package has been created with checkinstall using Base image
#
@@ -27,8 +28,10 @@
{{ $image := (or .Env.DOCKER_IMAGE "mesa") }}
{{ $distro := "xenial" }}
+{{ $basetag := (or .Env.CI_COMMIT_REF_SLUG "local") }}
+{{ $tag := (print $basetag "-llvm-" .LLVM) }}
-FROM {{ $image }}:base
+FROM {{ $image }}:{{ $basetag }}-base
LABEL maintainer "Juan A. Suarez Romero <jasuarez at igalia.com>"
LABEL dockerfile.sha256 {{ .DOCKERFILE_SHA256 }}
@@ -56,4 +59,4 @@ RUN apt-get update \
&& rm -fr /var/lib/apt/lists/*
{{ end }}
-TAG {{ $image }}:llvm-{{ .LLVM }}
+TAG {{ $image }}:{{ $tag }}
diff --git a/gitlab-ci/Rockerfile.mesa b/gitlab-ci/Rockerfile.mesa
index 23add521fc7..9a23d70297b 100644
--- a/gitlab-ci/Rockerfile.mesa
+++ b/gitlab-ci/Rockerfile.mesa
@@ -6,11 +6,11 @@
# --var BUILD=autotools # meson, scons, autotools, windows, distcheck, gallium \
# [--var DEBUG=true] # build with debug options (true, false) \
# [--var LLVM=3.3] # 3.3, 3.6, 3.8, 3.9, 4.0, ... \
-# [--var TAG=master] # master, staging-18.0, staging-18.1, ... \
# ~~~
#
# Environment variables that are used in the build:
-# - DOCKER_IMAGE: name of the final image to be tagged (default: mesa[:$TAG])
+# - CI_COMMIT_REF_SLUG: branch/tag name, escape
+# - DOCKER_IMAGE: name of the final image to be tagged (default: mesa[:$CI_COMMIT_REF_SLUG])
# - MAKEFLAGS: flags to pass to make (e.g., "-j8")
# - CCACHE_DIR: ccache directory (e.g., ~/.ccache)
#
@@ -18,13 +18,14 @@
{{ $image := (or .Env.DOCKER_IMAGE "mesa") }}
{{ $llvm_version := (or .LLVM "0.0") }}
{{ $debug_build := (or .DEBUG "true") }}
+{{ $tag := (or .Env.CI_COMMIT_REF_SLUG "local") }}
{{ if eq .BUILD "windows"}}
-FROM {{ $image }}:base
+FROM {{ $image }}:{{ $tag }}-base
{{ else if eq $llvm_version "0.0" }}
-FROM {{ $image }}:base
+FROM {{ $image }}:{{ $tag }}-base
{{ else }}
-FROM {{ $image }}:llvm-{{ .LLVM }}
+FROM {{ $image }}:{{ $tag }}-llvm-{{ .LLVM }}
{{ end }}
LABEL maintainer "Juan A. Suarez Romero <jasuarez at igalia.com>"
@@ -127,6 +128,6 @@ WORKDIR /home/local
USER root
-{{ if .TAG }}
-TAG {{ $image }}:{{ .TAG }}
+{{ if .Env.CI_COMMIT_REF_SLUG }}
+TAG {{ $image }}:{{ .Env.CI_COMMIT_REF_SLUG }}
{{ end }}
--
2.17.1
More information about the mesa-dev
mailing list