Add multiarch support to docker container, fixes https://git.pleroma.social/pleroma...
authorGuy Sheffer <guysoft@gmail.com>
Wed, 22 Jul 2020 14:26:36 +0000 (17:26 +0300)
committerGuy Sheffer <guysoft@gmail.com>
Wed, 22 Jul 2020 14:26:36 +0000 (17:26 +0300)
.gitlab-ci.yml

index c9ab848926f21debe460cee18509380aefdc3ffb..816c05b1e55439eb9011da39d14cbcb352a565d7 100644 (file)
@@ -285,10 +285,13 @@ docker:
     - export CI_VCS_REF=$CI_COMMIT_SHORT_SHA
   allow_failure: true
   script:
-    - docker build --cache-from $IMAGE_TAG_SLUG --build-arg VCS_REF=$CI_VCS_REF --build-arg BUILD_DATE=$CI_JOB_TIMESTAMP -t $IMAGE_TAG -t $IMAGE_TAG_SLUG -t $IMAGE_TAG_LATEST .
-    - docker push $IMAGE_TAG
-    - docker push $IMAGE_TAG_SLUG
-    - docker push $IMAGE_TAG_LATEST
+    - mkdir -p /root/.docker/cli-plugins
+    - wget https://github.com/docker/buildx/releases/download/v0.4.1/buildx-v0.4.1.linux-amd64 -O ~/.docker/cli-plugins/docker-buildx
+    - chmod +x ~/.docker/cli-plugins/docker-buildx
+    - docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
+    - docker buildx create --name mbuilder --driver docker-container --use
+    - docker buildx inspect --bootstrap
+    - docker buildx build --platform linux/amd64,linux/arm/v7 --push --cache-from $IMAGE_TAG_SLUG --build-arg VCS_REF=$CI_VCS_REF --build-arg BUILD_DATE=$CI_JOB_TIMESTAMP -t $IMAGE_TAG -t $IMAGE_TAG_SLUG -t $IMAGE_TAG_LATEST .
   tags:
     - dind
   only:
@@ -303,10 +306,13 @@ docker-stable:
   before_script: *before-docker
   allow_failure: true
   script:
-    - docker build --cache-from $IMAGE_TAG_SLUG --build-arg VCS_REF=$CI_VCS_REF --build-arg BUILD_DATE=$CI_JOB_TIMESTAMP -t $IMAGE_TAG -t $IMAGE_TAG_SLUG -t $IMAGE_TAG_LATEST_STABLE .
-    - docker push $IMAGE_TAG
-    - docker push $IMAGE_TAG_SLUG
-    - docker push $IMAGE_TAG_LATEST_STABLE
+    - mkdir -p /root/.docker/cli-plugins
+    - wget https://github.com/docker/buildx/releases/download/v0.4.1/buildx-v0.4.1.linux-amd64 -O ~/.docker/cli-plugins/docker-buildx
+    - chmod +x ~/.docker/cli-plugins/docker-buildx
+    - docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
+    - docker buildx create --name mbuilder --driver docker-container --use
+    - docker buildx inspect --bootstrap
+    - docker buildx build --platform linux/amd64,linux/arm/v7 --push --cache-from $IMAGE_TAG_SLUG --build-arg VCS_REF=$CI_VCS_REF --build-arg BUILD_DATE=$CI_JOB_TIMESTAMP -t $IMAGE_TAG -t $IMAGE_TAG_SLUG -t $IMAGE_TAG_LATEST_STABLE .
   tags:
     - dind
   only:
@@ -321,9 +327,14 @@ docker-release:
   before_script: *before-docker
   allow_failure: true
   script:
-    - docker build --cache-from $IMAGE_TAG_SLUG --build-arg VCS_REF=$CI_VCS_REF --build-arg BUILD_DATE=$CI_JOB_TIMESTAMP -t $IMAGE_TAG -t       $IMAGE_TAG_SLUG .
-    - docker push $IMAGE_TAG
-    - docker push $IMAGE_TAG_SLUG
+  script:
+    - mkdir -p /root/.docker/cli-plugins
+    - wget https://github.com/docker/buildx/releases/download/v0.4.1/buildx-v0.4.1.linux-amd64 -O ~/.docker/cli-plugins/docker-buildx
+    - chmod +x ~/.docker/cli-plugins/docker-buildx
+    - docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
+    - docker buildx create --name mbuilder --driver docker-container --use
+    - docker buildx inspect --bootstrap
+    - docker buildx build --platform linux/amd64,linux/arm/v7 --push --cache-from $IMAGE_TAG_SLUG --build-arg VCS_REF=$CI_VCS_REF --build-arg BUILD_DATE=$CI_JOB_TIMESTAMP -t $IMAGE_TAG -t $IMAGE_TAG_SLUG .
   tags:
     - dind
   only: