summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArkadiusz Hiler <arkadiusz.hiler@intel.com>2019-09-03 10:57:14 +0300
committerArkadiusz Hiler <arkadiusz.hiler@intel.com>2019-09-03 18:27:01 +0300
commit72cdaf6aadc16c42651722b8db71efc673da2b06 (patch)
tree81678b812bdff804acc286c8a7a15235ccbe44be
parent3bf2fc3dfbbbd5a6f5ff0fc8b417ee25e0f338b9 (diff)
.gitlab-ci: Don't pull images until they are needed
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@intel.com> Reviewed-by: Petri Latvala <petri.latvala@intel.com>
-rw-r--r--.gitlab-ci.yml4
-rwxr-xr-x.gitlab-ci/pull-or-rebuild.sh6
-rw-r--r--Dockerfile3
-rw-r--r--Dockerfile.build-debian3
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 \