From d3b015df3d2e07d732d725bc715c2f6d279048e4 Mon Sep 17 00:00:00 2001
From: Moritz Maxeiner <mm@ucw.sh>
Date: Mon, 6 Jul 2020 13:16:21 +0200
Subject: [PATCH] [ci] Use podman for building

- Building with nvidia-container-runtime results in host GPU driver libraries saved in the built image,
  which causes runtime failures when trying to run CUDA programs after host GPU drivers are updated.
- The docker daemon must be set to use nvidia-container-runtime by default, because neither docker-compose
  nor jupyterhub allow choosing a container runtime other than the default one.
- docker buildkit, which would be an alternative, fails to even start building
---
 .gitlab-ci.yml | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 6fd9db2..7d87cc2 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -6,12 +6,8 @@ build ubuntu:
   stage: build
   tags: [linux, shell]
   script:
-    - GPU_DRIVER_VERSION="$(dpkg-query --showformat='${Version}' --show 'nvidia-driver-*')"
-    - CACHE_FILE="/var/lib/gitlab-runner/.local/share/gpu-driver-version"
-    - if [[ -f $CACHE_FILE ]] && [[ "$(cat $CACHE_FILE)" == "$GPU_DRIVER_VERSION" ]]; then OPTS=''; else OPTS='--no-cache'; fi
-    - echo -n $GPU_DRIVER_VERSION > $CACHE_FILE
     - image_name="${CI_REGISTRY}/${CI_PROJECT_PATH,,}"
-    - docker build $OPTS --pull -t "${image_name}/ubuntu" -f ubuntu/Dockerfile ubuntu
+    - podman build --pull -t "${image_name}/ubuntu" ubuntu
 
 deploy ubuntu:
   stage: deploy
@@ -19,9 +15,9 @@ deploy ubuntu:
   only:
     - master
   before_script:
-    - echo "${CI_REGISTRY_PASSWORD}" | docker login -u "${CI_REGISTRY_USER}" "${CI_REGISTRY}" --password-stdin
+    - echo "${CI_REGISTRY_PASSWORD}" | podman login -u "${CI_REGISTRY_USER}" "${CI_REGISTRY}" --password-stdin
   script:
     - image_name="${CI_REGISTRY}/${CI_PROJECT_PATH,,}"
-    - docker push "${image_name}/ubuntu"
+    - podman push "${image_name}/ubuntu"
   after_script:
-    - docker logout "${CI_REGISTRY}"
+    - podman logout "${CI_REGISTRY}"
-- 
GitLab