[gtk/ci-docs] ci: Update the docker wrapper script



commit 7bc50b746600646b5cbadcd614f4a0b90a3a35fa
Author: Emmanuele Bassi <ebassi gnome org>
Date:   Tue Feb 25 19:05:07 2020 +0000

    ci: Update the docker wrapper script
    
    Do a better job at detecting whether we have Docker installed.

 .gitlab-ci/run-docker.sh | 33 +++++++++++++++++++--------------
 1 file changed, 19 insertions(+), 14 deletions(-)
---
diff --git a/.gitlab-ci/run-docker.sh b/.gitlab-ci/run-docker.sh
index dc9647bd4b..ef0f56154e 100755
--- a/.gitlab-ci/run-docker.sh
+++ b/.gitlab-ci/run-docker.sh
@@ -85,20 +85,25 @@ else
         base_version="v$base_version"
 fi
 
-TAG="registry.gitlab.gnome.org/gnome/gtk/${base}:${base_version}"
+if [ ! -x "$(command -v docker)" ] || [ 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.
+        echo "Using: Podman"
+        format="--format docker"
+        CMD="podman"
+else
+        echo "Using: Docker"
+        format=""
+        CMD="sudo socker"
+fi
 
-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
+REGISTRY="registry.gitlab.gnome.org"
+TAG="${REGISTRY}/gnome/gtk/${base}:${base_version}"
 
+if [ $build == 1 ]; then
         echo -e "\e[1;32mBUILDING\e[0m: ${base} as ${TAG}"
-        sudo docker build \
+        ${CMD} build \
                 ${format} \
                 --build-arg HOST_USER_ID="$UID" \
                 --tag "${TAG}" \
@@ -110,16 +115,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
+                ${CMD} login ${REGISTRY}
         fi
 
-        sudo docker push $TAG
+        ${CMD} push ${TAG}
         exit $?
 fi
 
 if [ $run == 1 ]; then
         echo -e "\e[1;32mRUNNING\e[0m: ${base} as ${TAG}"
-        sudo docker run \
+        ${CMD} 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]