[glib/wip/hadess/update-docker-packages: 33/36] ci: Expand podman support



commit 321aebefc352cfabec549e4b3ae864e7c97ed213
Author: Bastien Nocera <hadess hadess net>
Date:   Wed Dec 11 15:44:25 2019 +0100

    ci: Expand podman support
    
    If podman is used, as is usually the case on a Fedora Workstation
    installation, make sure not to use "sudo" as that's not needed.
    
    Also ask podman's backend (buildah) to create Docker compatible images
    through an environment variable rather than a command-line argument.
    
    See https://gitlab.gnome.org/GNOME/glib/merge_requests/1255

 .gitlab-ci/run-docker.sh | 28 ++++++++++++++--------------
 1 file changed, 14 insertions(+), 14 deletions(-)
---
diff --git a/.gitlab-ci/run-docker.sh b/.gitlab-ci/run-docker.sh
index 10a9b4816..e3afad88b 100755
--- a/.gitlab-ci/run-docker.sh
+++ b/.gitlab-ci/run-docker.sh
@@ -15,6 +15,16 @@ read_arg() {
     fi
 }
 
+SUDO_CMD="sudo"
+if `docker -v | grep -q podman` ; then
+        # Using podman
+        SUDO_CMD=""
+        # Docker is actually implemented by podman, and its OCI output
+        # is incompatible with some of the dockerd instances on GitLab
+        # CI runners.
+        BUILDAH_FORMAT=docker
+fi
+
 set -e
 
 build=0
@@ -88,18 +98,8 @@ fi
 TAG="registry.gitlab.gnome.org/gnome/glib/${base}:${base_version}"
 
 if [ $build == 1 ]; then
-        if docker --help |& grep -q podman; then
-                # Docker is actually implemented by podman, and its OCI output
-                # is incompatible with some of the dockerd instances on GitLab
-                # CI runners.
-                format="--format docker"
-        else
-                format=""
-        fi
-
         echo -e "\e[1;32mBUILDING\e[0m: ${base} as ${TAG}"
-        sudo docker build \
-                ${format} \
+        $SUDO_CMD docker build \
                 --build-arg HOST_USER_ID="$UID" \
                 --tag "${TAG}" \
                 --file "${base}.Dockerfile" .
@@ -110,16 +110,16 @@ if [ $push == 1 ]; then
         echo -e "\e[1;32mPUSHING\e[0m: ${base} as ${TAG}"
 
         if [ $no_login == 0 ]; then
-                sudo docker login registry.gitlab.gnome.org
+                $SUDO_CMD docker login registry.gitlab.gnome.org
         fi
 
-        sudo docker push $TAG
+        $SUDO_CMD docker push $TAG
         exit $?
 fi
 
 if [ $run == 1 ]; then
         echo -e "\e[1;32mRUNNING\e[0m: ${base} as ${TAG}"
-        sudo docker run \
+        $SUDO_CMD docker run \
                 --rm \
                 --volume "$(pwd)/..:/home/user/app" \
                 --workdir "/home/user/app" \


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]