gitlab-ci-multiplatform
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
gitlab-ci-multiplatform [2021/01/09 10:06] – baumi | gitlab-ci-multiplatform [2025/09/11 09:43] (current) – removed baumi | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== Gitlab CI MultiPlatform Build ====== | ||
- | ===== Enable Emulators ===== | ||
- | <code bash> | ||
- | $ docker run --rm --privileged tonistiigi/ | ||
- | { | ||
- | " | ||
- | " | ||
- | " | ||
- | " | ||
- | " | ||
- | " | ||
- | " | ||
- | " | ||
- | " | ||
- | ], | ||
- | " | ||
- | " | ||
- | " | ||
- | " | ||
- | " | ||
- | " | ||
- | ] | ||
- | } | ||
- | </ | ||
- | ===== Create buildx enabled docker image for builds ===== | ||
- | <file bash Dockerfile> | ||
- | ARG BUILDX_VERSION=0.4.2 | ||
- | ARG DOCKER_VERSION=latest | ||
- | |||
- | FROM alpine AS fetcher | ||
- | |||
- | RUN apk add curl | ||
- | |||
- | ARG BUILDX_VERSION | ||
- | RUN curl -L \ | ||
- | --output / | ||
- | " | ||
- | |||
- | RUN chmod a+x / | ||
- | |||
- | ARG DOCKER_VERSION | ||
- | FROM docker: | ||
- | |||
- | COPY --from=fetcher / | ||
- | </ | ||
- | |||
- | Credits to [[https:// | ||
- | |||
- | Build image | ||
- | |||
- | <code bash> | ||
- | $ docker build --pull -t registry/ | ||
- | $ docker push registry/ | ||
- | </ | ||
- | |||
- | ===== Switch to buildx in .gitlab-ci.yml ===== | ||
- | Define CI_PLATFORMS variable in Settings / CI/CD: | ||
- | |||
- | CI_PLATFORMS = linux/ | ||
- | |||
- | <file bash .gitlab-ci.yml> | ||
- | image: registry/ | ||
- | |||
- | 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 . | ||
- | </ | ||
- | {{tag>kb git}} |
gitlab-ci-multiplatform.1610183218.txt.gz · Last modified: by baumi