[tracker-oci-images/sam/podman: 1/5] Use Podman instead of Docker to build images



commit 787c3d058257bbe400713784053f863e3ebf63ba
Author: Sam Thursfield <sam afuera me uk>
Date:   Wed Dec 11 10:57:23 2019 +0100

    Use Podman instead of Docker to build images
    
    This pulls in a few updates from [librsvg-oci-images] which this
    project is based on:
    
      * Dockerfiles are not yml
          https://gitlab.gnome.org/GNOME/librsvg-oci-images/commit/f848d31ce6109eecfa3670570d51c37b502870a6
      * replace docker with podman/buildah
          https://gitlab.gnome.org/GNOME/librsvg-oci-images/commit/f1d0683eb47064d0cf947b2ea059b89fee7f5acb
      * fedora 30 as the image to bootstrap containers
          https://gitlab.gnome.org/GNOME/librsvg-oci-images/commit/a967189eef1cee3b0f2d4a85d45178c40c053bc9
    
    This should allow us to move beyond Fedora 30 to build the images at
    some point.
    
    librsvg-oci-images: https://gitlab.gnome.org/GNOME/librsvg-oci-images/

 .gitlab-ci.yml                  | 97 ++++++++++++++++++++---------------------
 fedora/{latest.yml => latest}   |  2 +-
 fedora/{rawhide.yml => rawhide} |  0
 3 files changed, 48 insertions(+), 51 deletions(-)
---
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 060e5ff..8386259 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -1,60 +1,57 @@
-image: docker:19.03.0
-services:
-    - docker:19.03.0-dind
-
-# When using dind, it's wise to use the overlayfs driver for
-# improved performance.
-variables:
-    DOCKER_DRIVER: overlay2
-    DOCKER_TLS_CERTDIR: ""
+image: 'registry.fedoraproject.org/fedora:30'
 
 stages:
-    - distro
+  - distro
+
+# Buildah can't use 'overlay' driver when running inside docker
+variables:
+  STORAGE_DRIVER: 'vfs'
 
 # Expects $IMAGE which should be the name+tag of the registry image.
-# Expects $OCI_YML variable which should be the path to the dockerfile
-# Expects $DIR variable which should be the name of the parrent folder of the dockerfile
-.base_template: &base_build
-    script:
-        - cd ${DIR}
-        - docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY
-        - docker build --pull -f ${OCI_YML} -t ${IMAGE} .
-        - docker images
-        - |
-          if [ "$CI_COMMIT_REF_NAME" = "master" ]; then
-              docker push ${IMAGE}
-          else
-              echo "Not pushing image, as we are on non-master branch $CI_COMMIT_REF_NAME"
-          fi
+# Expects $DOCKERFILE variable which should be the path to the dockerfile
+# Expects $CONTEXT_DIR variable which should be the name of the parrent folder of the dockerfile
+.base:
+  script:
+    - dnf install -y buildah podman
+    - buildah login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY
+
+    # Newer versions of podman/buildah try to set overlayfs mount options when
+    # using the vfs driver, and this causes errors.
+    - sed -i '/^mountopt =.*/d' /etc/containers/storage.conf
+
+    - podman build --format=docker --pull -f ${DOCKERFILE} -t ${IMAGE} ${CONTEXT_DIR}
+    - podman push ${IMAGE}
 
 # Expects $ARCH variable which should be the architexcture of the image ex. x86_64
 # Expects $DISTRO_NAME variable which should be the name of the distro image ex. ubuntu
 # Expects $DISTRO_VER variable which should be the version distro image ex. 18.04
-# Expects $OCI_YML variable which should be the path to the dockerfile
-.distro_template: &distro_build
-    stage: distro
-    before_script:
-        - export NAMESPACE="$(echo "${CI_PROJECT_NAMESPACE}" | tr A-Z a-z)"
-        - export IMAGE=${CI_REGISTRY}/${NAMESPACE}/${CI_PROJECT_NAME}/${ARCH}/${DISTRO_NAME}:${DISTRO_VER}
-    interruptible: true
-    <<: *base_build
-
-fedora:latest:
-    variables:
-      ARCH: "amd64"
-      DISTRO_NAME: "fedora"
-      DISTRO_VER: "latest"
-      OCI_YML: "latest.yml"
-      DIR: "fedora"
-
-    <<: *distro_build
+# Expects $DOCKERFILE variable which should be the path to the dockerfile
+.distro build:
+  stage: distro
+  before_script:
+    - export IMAGE=${CI_REGISTRY_IMAGE}/${ARCH}/${DISTRO_NAME}:${DISTRO_VER}
+  extends: '.base'
+
+fedora latest:
+  extends: '.distro build'
+  variables:
+    ARCH: "amd64"
+    DISTRO_NAME: "fedora"
+    DISTRO_VER: "latest"
+    DOCKERFILE: "fedora/latest"
+    CONTEXT_DIR: "fedora"
+  only:
+    changes:
+      - 'fedora/*'
 
 ubuntu:rolling:
-    variables:
-      ARCH: "amd64"
-      DISTRO_NAME: "ubuntu"
-      DISTRO_VER: "rolling"
-      OCI_YML: "ubuntu-rolling"
-      DIR: "debian"
-
-    <<: *distro_build
+  extends: '.distro build'
+  variables:
+    ARCH: "amd64"
+    DISTRO_NAME: "ubuntu"
+    DISTRO_VER: "rolling"
+    DOCKERFILE: "debian/ubuntu-rolling"
+    CONTEXT_DIR: "debian"
+  only:
+    changes:
+      - 'debian/*'
diff --git a/fedora/latest.yml b/fedora/latest
similarity index 69%
rename from fedora/latest.yml
rename to fedora/latest
index 026cf84..d85597e 100644
--- a/fedora/latest.yml
+++ b/fedora/latest
@@ -1,4 +1,4 @@
-FROM fedora:latest
+FROM registry.fedoraproject.org/fedora:latest
 
 COPY prepare.sh cleanup.sh /root/
 
diff --git a/fedora/rawhide.yml b/fedora/rawhide
similarity index 100%
rename from fedora/rawhide.yml
rename to fedora/rawhide


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