[igt-dev] [PATCH i-g-t 7/8] .gitlab-ci: Don't pull images until they are needed
Arkadiusz Hiler
arkadiusz.hiler at intel.com
Tue Sep 3 08:38:23 UTC 2019
We were pulling and tagging images locally ahead of time just in case
the next build may need it (i.e. debian-minimal for the fully featured
debian).
Instead of doing that we can specify the registry in Dockerfile's FROM
cluse, so the image is pulled only when we are need it.
Signed-off-by: Arkadiusz Hiler <arkadiusz.hiler at intel.com>
---
.gitlab-ci.yml | 4 ----
.gitlab-ci/pull-or-rebuild.sh | 6 ++++--
Dockerfile | 3 ++-
Dockerfile.build-debian | 3 ++-
4 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 07c9a628..c57d86c3 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -28,8 +28,6 @@ build-containers:build-debian:
script:
- podman login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY
- .gitlab-ci/pull-or-rebuild.sh base Dockerfile.build-debian-minimal build-debian-minimal
- - podman pull $CI_REGISTRY/$CI_PROJECT_PATH/build-debian-minimal:commit-$CI_COMMIT_SHA
- - podman 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 base Dockerfile.build-debian build-debian
build-containers:build-debian-armhf:
@@ -266,6 +264,4 @@ containers:igt:
FORCE_REBUILD: 1
script:
- podman login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY
- - podman pull $CI_REGISTRY/$CI_PROJECT_PATH/build-fedora:commit-$CI_COMMIT_SHA
- - podman tag $CI_REGISTRY/$CI_PROJECT_PATH/build-fedora:commit-$CI_COMMIT_SHA build-fedora:commit-$CI_COMMIT_SHA
- .gitlab-ci/pull-or-rebuild.sh igt Dockerfile igt
diff --git a/.gitlab-ci/pull-or-rebuild.sh b/.gitlab-ci/pull-or-rebuild.sh
index 7b3bb84c..a9409db8 100755
--- a/.gitlab-ci/pull-or-rebuild.sh
+++ b/.gitlab-ci/pull-or-rebuild.sh
@@ -34,6 +34,8 @@ REFNAME=$IMAGENAME:$REF
DOCKERNAME=$IMAGENAME:dockerfile-$DOCKERFILE_CHECKSUM
COMMITNAME=$IMAGENAME:commit-$CI_COMMIT_SHA
+PODMAN_BUILD="podman build --build-arg=CI_COMMIT_SHA=$CI_COMMIT_SHA --build-arg=CI_REGISTRY_IMAGE=$CI_REGISTRY_IMAGE"
+
if [ "$TYPE" = "base" ]; then
# base container (building, etc) - we rebuild only if changed or forced
skopeo inspect docker://$DOCKERNAME
@@ -44,7 +46,7 @@ if [ "$TYPE" = "base" ]; then
echo "Skipping, already built"
else
echo "Building!"
- podman build --squash --build-arg=CI_COMMIT_SHA=$CI_COMMIT_SHA -t $DOCKERNAME -f $DOCKERFILE .
+ $PODMAN_BUILD --squash -t $DOCKERNAME -f $DOCKERFILE .
podman push $DOCKERNAME
fi
@@ -53,7 +55,7 @@ elif [ "$TYPE" = "igt" ]; then
# container with IGT, we don't care about Dockerfile changes
# we always rebuild
set -e
- podman build --build-arg=CI_COMMIT_SHA=$CI_COMMIT_SHA -t $COMMITNAME -f $DOCKERFILE .
+ $PODMAN_BUILD -t $COMMITNAME -f $DOCKERFILE .
podman push $COMMITNAME
skopeo copy docker://$COMMITNAME docker://$REFNAME
else
diff --git a/Dockerfile b/Dockerfile
index 6f2f62ec..2fe0e340 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -1,5 +1,6 @@
ARG CI_COMMIT_SHA
-FROM build-fedora:commit-$CI_COMMIT_SHA
+ARG CI_REGISTRY_IMAGE
+FROM $CI_REGISTRY_IMAGE/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 de2adca6..69f63157 100644
--- a/Dockerfile.build-debian
+++ b/Dockerfile.build-debian
@@ -1,5 +1,6 @@
ARG CI_COMMIT_SHA
-FROM build-debian-minimal:commit-$CI_COMMIT_SHA
+ARG CI_REGISTRY_IMAGE
+FROM $CI_REGISTRY_IMAGE/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