[igt-dev] [PATCH i-g-t 2/8] Dockerfile: Make sure that we use correct base image

Arkadiusz Hiler arkadiusz.hiler at intel.com
Tue Sep 3 08:36:08 UTC 2019


Correct one = the one tagged with current commit, so in case of parallel
pipelines we don't take the wrong "latest".

Signed-off-by: Arkadiusz Hiler <arkadiusz.hiler at intel.com>
---
 .gitlab-ci.yml                | 4 +++-
 .gitlab-ci/pull-or-rebuild.sh | 5 +++--
 Dockerfile                    | 4 ++--
 Dockerfile.build-debian       | 3 ++-
 4 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index df2b5f55..c5611138 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -31,6 +31,8 @@ build-containers:build-debian:
   script:
     - docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY
     - .gitlab-ci/pull-or-rebuild.sh Dockerfile.build-debian-minimal build-debian-minimal
+    - docker pull $CI_REGISTRY/$CI_PROJECT_PATH/build-debian-minimal:commit-$CI_COMMIT_SHA
+    - docker tag $CI_REGISTRY/$CI_PROJECT_PATH/build-debian-minimal:commit-$CI_COMMIT_SHA build-debian-minimal:commit-$CI_COMMIT_SHA
     - .gitlab-ci/pull-or-rebuild.sh Dockerfile.build-debian build-debian
 
 build-containers:build-debian-armhf:
@@ -293,5 +295,5 @@ containers:igt:
   script:
     - docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY
     - docker pull $CI_REGISTRY/$CI_PROJECT_PATH/build-fedora:commit-$CI_COMMIT_SHA
-    - docker tag $CI_REGISTRY/$CI_PROJECT_PATH/build-fedora:commit-$CI_COMMIT_SHA build-fedora
+    - docker tag $CI_REGISTRY/$CI_PROJECT_PATH/build-fedora:commit-$CI_COMMIT_SHA build-fedora:commit-$CI_COMMIT_SHA
     - .gitlab-ci/pull-or-rebuild.sh Dockerfile igt
diff --git a/.gitlab-ci/pull-or-rebuild.sh b/.gitlab-ci/pull-or-rebuild.sh
index 182c8d49..9f33b414 100755
--- a/.gitlab-ci/pull-or-rebuild.sh
+++ b/.gitlab-ci/pull-or-rebuild.sh
@@ -44,8 +44,9 @@ if [ $IMAGE_PRESENT -eq 0 ] && [ ${FORCE_REBUILD:-0} -eq 0 ] ; then
 	docker tag $DOCKERNAME $COMMITNAME
 else
 	echo "Building $NAME:$TAG"
-	docker build -t $DOCKERNAME -t $NAME \
-		     -t $REFNAME -t $COMMITNAME -f $DOCKERFILE .
+	docker build --build-arg=CI_COMMIT_SHA=$CI_COMMIT_SHA \
+			 -t $DOCKERNAME -t $NAME \
+			 -t $REFNAME -t $COMMITNAME -f $DOCKERFILE .
 	docker push $DOCKERNAME
 fi
 docker push $REFNAME
diff --git a/Dockerfile b/Dockerfile
index 7ea266d3..6f2f62ec 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -1,5 +1,5 @@
-# Version number to bump for force image rebuild: 0
-FROM build-fedora
+ARG CI_COMMIT_SHA
+FROM build-fedora:commit-$CI_COMMIT_SHA
 
 COPY opt-igt /opt/igt
 COPY .gitlab-ci/docker-help.sh /usr/local/bin/docker-help.sh
diff --git a/Dockerfile.build-debian b/Dockerfile.build-debian
index 2749b177..13553c5a 100644
--- a/Dockerfile.build-debian
+++ b/Dockerfile.build-debian
@@ -1,4 +1,5 @@
-FROM build-debian-minimal
+ARG CI_COMMIT_SHA
+FROM build-debian-minimal:commit-$CI_COMMIT_SHA
 
 RUN apt-get update
 RUN apt-get install -y \
-- 
2.21.0



More information about the igt-dev mailing list