User Tools

Site Tools


gitlab-ci-multiplatform

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
gitlab-ci-multiplatform [2021/01/08 07:57] – [Create buildx image to use] baumigitlab-ci-multiplatform [2021/01/09 10:07] (current) – [Enable Emulators] baumi
Line 1: Line 1:
 ====== Gitlab CI MultiPlatform Build ====== ====== Gitlab CI MultiPlatform Build ======
  
-===== Enable Emulators ===== +===== Enable binary formats ===== 
-<code> +<code bash
-docker run -it --rm --privileged tonistiigi/binfmt --install all+docker run --rm --privileged tonistiigi/binfmt --install all
 { {
   "supported": [   "supported": [
Line 24: Line 24:
 } }
 </code> </code>
- +===== Create buildx enabled docker image for builds ===== 
-===== Create buildx image to use ===== +<file bash Dockerfile>
-<file Dockerfile>+
 ARG BUILDX_VERSION=0.4.2 ARG BUILDX_VERSION=0.4.2
 ARG DOCKER_VERSION=latest ARG DOCKER_VERSION=latest
Line 45: Line 44:
  
 COPY --from=fetcher /docker-buildx /usr/lib/docker/cli-plugins/docker-buildx COPY --from=fetcher /docker-buildx /usr/lib/docker/cli-plugins/docker-buildx
 +</file>
  
 +Credits to [[https://github.com/jdrouet|Jérémie Drouet]]
 +
 +==== Build & push image ====
 +
 +<code bash>
 +$ docker build --pull -t registry/docker-with-buildx .
 +$ docker push registry/docker-with-buildx
 </code> </code>
-===== Configure gitlab-runner ===== 
  
-===== Utilize own buildx image and switch to buildx in .gitlab-ci.yml =====+===== Switch to buildx in .gitlab-ci.yml ===== 
 +Define CI_PLATFORMS variable in Settings / CI/CD: 
 + 
 +CI_PLATFORMS = linux/amd64,linux/arm/v7,...
  
 +<file bash .gitlab-ci.yml>
 +image: registry/docker-with-buildx
  
 +services:
 +  - docker:dind
  
 +build:
 +  stage: build
 +  script:
 +    - docker login -u $CI_USER -p $CI_TOKEN $CI_REGISTRY
 +    - docker buildx create --use
 +    - docker buildx build --platform $CI_PLATFORMS --push --pull -t $CI_REGISTRY_IMAGE .
 +</file>
 +{{tag>kb git}}
gitlab-ci-multiplatform.1610089043.txt.gz · Last modified: 2021/01/08 07:57 by baumi

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki