28 Commits
0.0.1 ... 0.2.0

Author SHA1 Message Date
acc2f9f6a6 build(version): bump version 0.1.0 → 0.2.0 2023-05-21 06:08:15 +00:00
Jon
323b5087cd Merge branch 'non-specific-development' into 'development'
chore: non specific development

See merge request nofusscomputing/projects/docker-buildx-qemu!4
2023-05-21 05:49:59 +00:00
Jon
e49f78f712 docs(readme): added usage within gitlab-ci
!4
2023-05-21 13:32:33 +09:30
Jon
d352f0e899 feat(build): use debian slim
!4
2023-05-21 02:42:21 +09:30
Jon
5f80d34f4e chore: cleanup
!4
2023-05-21 02:12:01 +09:30
Jon
692457da01 ci(gitlab-ci): update to current HEAD
!4
2023-05-21 02:01:15 +09:30
Jon
a00cfd60b8 ci: remove qemu from image
!4
2023-05-21 01:36:01 +09:30
Jon
698002d9f4 fix(qemu): segfault on arm no longer occurs
qemu was segfaulting with:
```
    Processing triggers for libc-bin (2.31-13+deb11u6) ...
    qemu: uncaught target signal 11 (Segmentation fault) - core dumped
    Segmentation fault (core dumped)
    qemu: uncaught target signal 11 (Segmentation fault) - core dumped
    Segmentation fault (core dumped)
    dpkg: error processing package libc-bin (--configure):
    installed libc-bin package post-installation script subprocess returned error exit status 139
    ```
so qemu was removed from the image

!4
2023-05-20 15:02:44 +09:30
Jon
8ddf6194c4 fix(docker): removed spt for armv7 and i386
docker-ce-cli not available for architecture

!4
2023-05-20 14:56:02 +09:30
Jon
06b65d9919 ci: update to current gitlab-ci project dev head
incorporates changes from nofusscomputing/projects/gitlab-ci!17

!4
2023-05-15 13:44:15 +09:30
e4bfd4b5fc build(version): bump version 0.0.1 → 0.1.0 2023-05-15 03:07:35 +00:00
Jon
d97525e193 Merge branch 'genesis' into 'development'
refactor: update project

See merge request nofusscomputing/projects/docker-buildx-qemu!1
2023-05-15 02:20:53 +00:00
Jon
45747fe6e0 ci: update to current gitlab-ci project dev head
incorporates changes from nofusscomputing/projects/gitlab-ci!17

!1 nofusscomputing/projects/gitlab-ci!17
2023-05-15 10:57:11 +09:30
Jon
9cabecb460 chore: update submodule to current dev
!1
2023-05-14 16:16:58 +09:30
Jon
b229fd8eb9 ci: enable jobs validation and git mirror and release
!1
2023-05-13 15:46:49 +09:30
Jon
be82a6cc90 ci: add sync to github
!1
2023-05-13 15:26:15 +09:30
Jon
76b3b6d6c1 ci: completely use gitlab-ci project for pipeline
!1
2023-05-13 15:13:42 +09:30
Jon
80a440f855 fix: libc issues workaround added
!1
2023-05-13 15:13:10 +09:30
Jon
b242911657 fix: set apt to be noninteractive
!1
2023-05-13 15:12:14 +09:30
Jon
8af1cee946 feat(software): install git
!1
2023-05-13 15:11:09 +09:30
Jon
069a47808a feat(software): install buildx plugin from docker repo
!1
2023-05-13 15:10:41 +09:30
Jon
92c1cefb95 feat(image): add python3 and pip
!1
2023-05-13 15:09:17 +09:30
Jon
03c98a8c81 feat(ci): use nfc gitlab-ci project
!1
2023-05-13 15:07:26 +09:30
Jon
d86b5b35df feat(build): add commitizen for versioning
!1
2023-05-13 15:06:33 +09:30
Jon
72a0c3f9d7 docs: clean readme
!1
2023-05-13 15:05:43 +09:30
Jon
ef1c9501f5 ci(build): don't retry build
dont auto retry as a failure should be investigated

!1
2023-05-12 10:44:33 +09:30
Jon
7f1ce78610 chore: add licence
!1
2023-05-12 10:43:41 +09:30
Jon
00ec401689 chore: remove additional gitlab-ci file
!1
2023-05-12 10:43:27 +09:30
10 changed files with 139 additions and 255 deletions

7
.cz.yaml Normal file
View File

@ -0,0 +1,7 @@
commitizen:
bump_message: "build(version): bump version $current_version \u2192 $new_version"
changelog_incremental: false
name: cz_conventional_commits
tag_format: $major.$minor.$patch$prerelease
update_changelog_on_bump: true
version: 0.2.0

View File

@ -1,124 +1,30 @@
# available variables, do not uncomment all at once.
# variables:
# CI_BUILDX_ARCHS: "linux/amd64,linux/arm64,linux/arm/v6,linux/arm/v7"
# CI_BUILD_ARM: true
# CI_BUILD_ARM64: true
# CI_AMD64_DISABLED: true
.build:
image: docker:dind
stage: build
services:
- name: docker:dind
entrypoint: ["env", "-u", "DOCKER_HOST"]
command: ["dockerd-entrypoint.sh"]
variables:
DOCKER_HOST: tcp://docker:2375/
DOCKER_DRIVER: overlay2
# See https://github.com/docker-library/docker/pull/166
DOCKER_TLS_CERTDIR: ""
retry: 2
before_script:
- |
if [[ -z "$CI_COMMIT_TAG" ]]; then
export CI_APPLICATION_REPOSITORY=${CI_APPLICATION_REPOSITORY:-$CI_REGISTRY_IMAGE/$CI_COMMIT_REF_SLUG}
export CI_APPLICATION_TAG=${CI_APPLICATION_TAG:-$CI_COMMIT_SHA}
else
export CI_APPLICATION_REPOSITORY=${CI_APPLICATION_REPOSITORY:-$CI_REGISTRY_IMAGE}
export CI_APPLICATION_TAG=${CI_APPLICATION_TAG:-$CI_COMMIT_TAG}
fi
- echo "$CI_REGISTRY_PASSWORD" | docker login -u $CI_REGISTRY_USER --password-stdin $CI_REGISTRY
include:
- project: nofusscomputing/projects/gitlab-ci
ref: development
file:
- .gitlab-ci_common.yaml
- template/docker-image.gitlab-ci.yaml
# these images depend on this repos image
# it must exist for for the arch that the gitlab-runner has.
build:buildx-master:
extends: .build
# set the image because we are using buildx here.
image: $CI_REGISTRY_IMAGE:latest
only:
refs:
- master
variables:
- $CI_BUILDX_ARCHS
script:
# Use docker-container driver to allow useful features (push/multi-platform)
- update-binfmts --enable # Important: Ensures execution of other binary formats is enabled in the kernel
- docker buildx create --driver docker-container --use
- docker buildx inspect --bootstrap
- docker buildx ls
- docker buildx build --platform $CI_BUILDX_ARCHS --progress plain --pull -t "$CI_REGISTRY_IMAGE" --push .
build:buildx:
extends: .build
# set the image because we are using buildx here.
image: $CI_REGISTRY_IMAGE:latest
only:
variables:
- $CI_BUILDX_ARCHS
except:
refs:
- master
script:
- update-binfmts --enable # Important: Ensures execution of other binary formats is enabled in the kernel
- docker buildx create --driver docker-container --use
- docker buildx inspect --bootstrap
- docker buildx ls
- docker buildx build --platform $CI_BUILDX_ARCHS --progress plain --pull -t "$CI_APPLICATION_REPOSITORY:$CI_APPLICATION_TAG" --push .
variables:
MY_PROJECT_ID: "45926238"
# disable build:armv7 for now since it seems to have an issue with dind
.build:arm:
extends: .build
only:
variables:
- $CI_BUILD_ARM
except:
variables:
- $CI_BUILDX_ARCHS
tags:
- arm
script:
- docker build -t "$CI_APPLICATION_REPOSITORY/arm:$CI_APPLICATION_TAG" .
- docker push "$CI_APPLICATION_REPOSITORY/arm:$CI_APPLICATION_TAG"
GIT_SYNC_URL: "https://$GITHUB_USERNAME_ROBOT:$GITHUB_TOKEN_ROBOT@github.com/NoFussComputing/docker-buildx-qemu.git"
#JOB_STOP_CONVENTIONAL_COMMITS: 'disable for testing'
#JOB_STOP_GIT_PUSH_MIRROR: 'disable for testing'
#JOB_STOP_GITLAB_RELEASE: 'disable for testing'
DOCKER_IMAGE_BUILD_TARGET_PLATFORMS: "linux/amd64,linux/amd64/v2,linux/amd64/v3,linux/arm64,linux/arm/v7"
# Package docker-ce-cli is not available for:
# - linux/arm/v6
# - linux/386
DOCKER_IMAGE_PUBLISH_NAME: $CI_PROJECT_NAME
DOCKER_IMAGE_PUBLISH_REGISTRY: docker.io/nofusscomputing
DOCKER_IMAGE_PUBLISH_URL: https://hub.docker.com/r/nofusscomputing/$DOCKER_IMAGE_PUBLISH_NAME
build:arm64:
extends: .build
only:
variables:
- $CI_BUILD_ARM64
except:
variables:
- $CI_BUILDX_ARCHS
tags:
- arm64
script:
- docker build -t "$CI_APPLICATION_REPOSITORY/arm64:$CI_APPLICATION_TAG" .
- docker push "$CI_APPLICATION_REPOSITORY/arm64:$CI_APPLICATION_TAG"
# builds this by default
build:amd64:
extends: .build
except:
variables:
- $CI_AMD64_DISABLED
- $CI_BUILDX_ARCHS
script:
- docker build -t "$CI_APPLICATION_REPOSITORY/amd64:$CI_APPLICATION_TAG" .
- docker push "$CI_APPLICATION_REPOSITORY/amd64:$CI_APPLICATION_TAG"
build:manifest:
extends: .build
stage: deploy
except:
variables:
- $CI_BUILDX_ARCHS
script:
- echo "Checking amd86 build..." && [[ -z $CI_AMD64_DISABLED ]] && echo "found" && export CI_MANIFEST_LIST="$CI_APPLICATION_REPOSITORY/amd64:$CI_APPLICATION_TAG"
- echo "Checking arm build..." && [[ $CI_BUILD_ARM ]] && echo "found" && export CI_MANIFEST_LIST="$CI_MANIFEST_LIST $CI_APPLICATION_REPOSITORY/arm:$CI_APPLICATION_TAG"
- echo "Checking arm64 build..." && [[ $CI_BUILD_ARM64 ]] && echo "found" && export CI_MANIFEST_LIST="$CI_MANIFEST_LIST $CI_APPLICATION_REPOSITORY/arm64:$CI_APPLICATION_TAG"
- export DOCKER_CLI_EXPERIMENTAL=enabled
- echo $CI_MANIFEST_LIST
- docker manifest create $CI_APPLICATION_REPOSITORY:$CI_APPLICATION_TAG $CI_MANIFEST_LIST && docker manifest push $CI_APPLICATION_REPOSITORY:$CI_APPLICATION_TAG
- docker manifest create $CI_APPLICATION_REPOSITORY:latest $CI_MANIFEST_LIST && docker manifest push $CI_APPLICATION_REPOSITORY:latest
- echo "Checking master" && [[ $CI_COMMIT_REF_NAME == "master" ]] && docker manifest create $CI_REGISTRY_IMAGE:latest $CI_MANIFEST_LIST && docker manifest push $CI_REGISTRY_IMAGE:latest

4
.gitmodules vendored Normal file
View File

@ -0,0 +1,4 @@
[submodule "gitlab-ci"]
path = gitlab-ci
url = https://gitlab.com/nofusscomputing/projects/gitlab-ci.git
branch = development

53
CHANGELOG.md Normal file
View File

@ -0,0 +1,53 @@
## 0.2.0 (2023-05-21)
### Bug Fixes
- **qemu**: [698002d9](https://gitlab.com/nofusscomputing/projects/docker-buildx-qemu/-/commit/698002d9f48f7ca1f033aeec2fc848646f177e6d) - segfault on arm no longer occurs [ [!4](https://gitlab.com/nofusscomputing/projects/docker-buildx-qemu/-/merge_requests/4) ]
- **docker**: [8ddf6194](https://gitlab.com/nofusscomputing/projects/docker-buildx-qemu/-/commit/8ddf6194c41a0f0991d7a66b9730f77c64c99c68) - removed spt for armv7 and i386 [ [!4](https://gitlab.com/nofusscomputing/projects/docker-buildx-qemu/-/merge_requests/4) ]
### Continious Integration
- **gitlab-ci**: [692457da](https://gitlab.com/nofusscomputing/projects/docker-buildx-qemu/-/commit/692457da01e5efa149ddbe16a3415880e3b60beb) - update to current HEAD [ [!4](https://gitlab.com/nofusscomputing/projects/docker-buildx-qemu/-/merge_requests/4) ]
- [a00cfd60](https://gitlab.com/nofusscomputing/projects/docker-buildx-qemu/-/commit/a00cfd60b887a0354638c97608b513f4cdafacd7) - remove qemu from image [ [!4](https://gitlab.com/nofusscomputing/projects/docker-buildx-qemu/-/merge_requests/4) ]
- [06b65d99](https://gitlab.com/nofusscomputing/projects/docker-buildx-qemu/-/commit/06b65d9919a6f0007cc347a75de6ab805635a4a9) - update to current gitlab-ci project dev head [ [!17](https://gitlab.com/nofusscomputing/projects/docker-buildx-qemu/-/merge_requests/17) [!4](https://gitlab.com/nofusscomputing/projects/docker-buildx-qemu/-/merge_requests/4) ]
### Documentaton / Guides
- **readme**: [e49f78f7](https://gitlab.com/nofusscomputing/projects/docker-buildx-qemu/-/commit/e49f78f712ea84f7d411e8916b1a7f8b87b26e22) - added usage within gitlab-ci [ [!4](https://gitlab.com/nofusscomputing/projects/docker-buildx-qemu/-/merge_requests/4) ]
### Features
- **build**: [d352f0e8](https://gitlab.com/nofusscomputing/projects/docker-buildx-qemu/-/commit/d352f0e899d5da43a23ebe25167718f947149cf4) - use debian slim [ [!4](https://gitlab.com/nofusscomputing/projects/docker-buildx-qemu/-/merge_requests/4) ]
## 0.1.0 (2023-05-15)
### Bug Fixes
- [80a440f8](https://gitlab.com/nofusscomputing/projects/docker-buildx-qemu/-/commit/80a440f855757c3d3e2b058fbd39fe2fc4484fb3) - libc issues workaround added [ [!1](https://gitlab.com/nofusscomputing/projects/docker-buildx-qemu/-/merge_requests/1) ]
- [b2429116](https://gitlab.com/nofusscomputing/projects/docker-buildx-qemu/-/commit/b24291165772b415800a68dd40e048ce666af0be) - set apt to be noninteractive [ [!1](https://gitlab.com/nofusscomputing/projects/docker-buildx-qemu/-/merge_requests/1) ]
### Continious Integration
- [45747fe6](https://gitlab.com/nofusscomputing/projects/docker-buildx-qemu/-/commit/45747fe6e0d54c3168cf90764952b756b21edf65) - update to current gitlab-ci project dev head [ [!17](https://gitlab.com/nofusscomputing/projects/docker-buildx-qemu/-/merge_requests/17) [!1](https://gitlab.com/nofusscomputing/projects/docker-buildx-qemu/-/merge_requests/1) [!17](https://gitlab.com/nofusscomputing/projects/docker-buildx-qemu/-/merge_requests/17) ]
- [b229fd8e](https://gitlab.com/nofusscomputing/projects/docker-buildx-qemu/-/commit/b229fd8eb9a06d7a09e6538777b7e27938ff2ac6) - enable jobs validation and git mirror and release [ [!1](https://gitlab.com/nofusscomputing/projects/docker-buildx-qemu/-/merge_requests/1) ]
- [be82a6cc](https://gitlab.com/nofusscomputing/projects/docker-buildx-qemu/-/commit/be82a6cc90508ff628768657024c53cac9745bb4) - add sync to github [ [!1](https://gitlab.com/nofusscomputing/projects/docker-buildx-qemu/-/merge_requests/1) ]
- [76b3b6d6](https://gitlab.com/nofusscomputing/projects/docker-buildx-qemu/-/commit/76b3b6d6c11672b579106e5911fa67b8fcdb3a7e) - completely use gitlab-ci project for pipeline [ [!1](https://gitlab.com/nofusscomputing/projects/docker-buildx-qemu/-/merge_requests/1) ]
- **build**: [ef1c9501](https://gitlab.com/nofusscomputing/projects/docker-buildx-qemu/-/commit/ef1c9501f51c9e4d969e66e9d488181dcc36c76b) - don't retry build [ [!1](https://gitlab.com/nofusscomputing/projects/docker-buildx-qemu/-/merge_requests/1) ]
### Documentaton / Guides
- [72a0c3f9](https://gitlab.com/nofusscomputing/projects/docker-buildx-qemu/-/commit/72a0c3f9d7f0cbdb4da49437242eba7d0d3e339f) - clean readme [ [!1](https://gitlab.com/nofusscomputing/projects/docker-buildx-qemu/-/merge_requests/1) ]
### Features
- **software**: [8af1cee9](https://gitlab.com/nofusscomputing/projects/docker-buildx-qemu/-/commit/8af1cee94657544b07f14103b257e04b57f0b781) - install git [ [!1](https://gitlab.com/nofusscomputing/projects/docker-buildx-qemu/-/merge_requests/1) ]
- **software**: [069a4780](https://gitlab.com/nofusscomputing/projects/docker-buildx-qemu/-/commit/069a47808a44b0cd1b23e2b526e28aca688406b0) - install buildx plugin from docker repo [ [!1](https://gitlab.com/nofusscomputing/projects/docker-buildx-qemu/-/merge_requests/1) ]
- **image**: [92c1cefb](https://gitlab.com/nofusscomputing/projects/docker-buildx-qemu/-/commit/92c1cefb9550ec526d3149edb33d43e25dcdfd75) - add python3 and pip [ [!1](https://gitlab.com/nofusscomputing/projects/docker-buildx-qemu/-/merge_requests/1) ]
- **ci**: [03c98a8c](https://gitlab.com/nofusscomputing/projects/docker-buildx-qemu/-/commit/03c98a8c814e0b26fb67949b96374fc6a35944a9) - use nfc gitlab-ci project [ [!1](https://gitlab.com/nofusscomputing/projects/docker-buildx-qemu/-/merge_requests/1) ]
- **build**: [d86b5b35](https://gitlab.com/nofusscomputing/projects/docker-buildx-qemu/-/commit/d86b5b35df494dfbc332b41035d2acf40d6fe1b4) - add commitizen for versioning [ [!1](https://gitlab.com/nofusscomputing/projects/docker-buildx-qemu/-/merge_requests/1) ]
## 0.0.1 (2023-05-12)
### Documentaton / Guides
- **readme**: [2b65dcbd](https://gitlab.com/nofusscomputing/projects/docker-buildx-qemu/-/commit/2b65dcbdeda1b29517735a3d87fcd2ba1014acaa) - updated to current format [ [!1](https://gitlab.com/nofusscomputing/projects/docker-buildx-qemu/-/merge_requests/1) ]

View File

@ -1,26 +0,0 @@
FROM debian
# Install Docker and qemu
# TODO Use docker stable once it properly supports buildx
RUN apt-get update && apt-get install -y \
apt-transport-https \
ca-certificates \
curl \
gnupg2 \
software-properties-common && \
curl -fsSL https://download.docker.com/linux/debian/gpg | apt-key add - && \
add-apt-repository "deb https://download.docker.com/linux/debian $(lsb_release -cs) stable" && \
apt-get update && apt-get install -y \
docker-ce-cli \
binfmt-support \
qemu-user-static
# Install buildx plugin
RUN mkdir -p ~/.docker/cli-plugins && \
ARCH=`dpkg --print-architecture` && echo Running on $ARCH && curl -s https://api.github.com/repos/docker/buildx/releases/latest | \
grep "browser_download_url.*linux-$ARCH" | cut -d : -f 2,3 | tr -d \" | \
xargs curl -L -o ~/.docker/cli-plugins/docker-buildx && \
chmod a+x ~/.docker/cli-plugins/docker-buildx
# Write version file
RUN printf "$(docker --version | perl -pe 's/^.*\s(\d+\.\d+\.\d+.*),.*$/$1/')_$(docker buildx version | perl -pe 's/^.*v?(\d+\.\d+\.\d+).*$/$1/')" > /version && \
cat /version

10
LICENSE Normal file
View File

@ -0,0 +1,10 @@
MIT License
Copyright
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

View File

@ -28,7 +28,7 @@ This project is hosted on [gitlab](https://gitlab.com/nofusscomputing/projects/d
**Development Branch**
![Gitlab build status - development](https://img.shields.io/badge/dynamic/json?color=ff782e&label=Build&query=0.status&url=https%3A%2F%2Fgitlab.com%2Fapi%2Fv4%2Fprojects%2F45926238%2Fpipelines%3Fref%3Ddevelopment&logo=gitlab&style=plastic) ![branch release version](https://img.shields.io/badge/dynamic/yaml?color=ff782e&logo=gitlab&style=plastic&label=Release&query=%24.commitizen.version&url=https%3A//gitlab.com/nofusscomputing/projects/docker-buildx-qemu-%2Fraw%2Fdevelopment%2F.cz.yaml)
![Gitlab build status - development](https://img.shields.io/badge/dynamic/json?color=ff782e&label=Build&query=0.status&url=https%3A%2F%2Fgitlab.com%2Fapi%2Fv4%2Fprojects%2F45926238%2Fpipelines%3Fref%3Ddevelopment&logo=gitlab&style=plastic) ![branch release version](https://img.shields.io/badge/dynamic/yaml?color=ff782e&logo=gitlab&style=plastic&label=Release&query=%24.commitizen.version&url=https%3A//gitlab.com/nofusscomputing/projects/docker-buildx-qemu%2F-%2Fraw%2Fdevelopment%2F.cz.yaml)
----
<br>
@ -45,6 +45,23 @@ links:
> This is a fork of https://gitlab.com/gdunstone/docker-buildx-qemu, which appears to be a fork of a fork. anyhow, updates are required. Credit to original and derivitive devs/contributors for getting it to the stage they had!!
This docker image enables building of multi-architecture docker builds. It's designed to run within a CI environment.
To use this image within Gitlab CI/CD Pipelines the following as a minimum is required within your `gitlab-ci.yaml` file, specifically the `before_script` section of your `docker buildx build` job:
``` yaml
before_script:
# see: https://gitlab.com/gitlab-org/gitlab-runner/-/merge_requests/1861
# on why this `docker run` is required. without it multiarch support doesnt work.
- docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
- update-binfmts --display
- update-binfmts --enable # Important: Ensures execution of other binary formats is enabled in the kernel
- docker buildx create --driver=docker-container --driver-opt image=moby/buildkit:v0.11.6 --use
- docker buildx inspect --bootstrap
```
When the above is added to the `before_script` section of the docker container build job, Gitlab CI has been initialized for multi-architecture builds.
## Contributing
All contributions for this project must conducted from [Gitlab](https://gitlab.com/nofusscomputing/projects/docker-buildx-qemu).
@ -55,70 +72,3 @@ For further details on contributing please refer to the [contribution guide](CON
## Other
This repo is release under this [license](LICENSE)
<details>
<summary>Original README.md</summary>
# docker-buildx-qemu
> this is a fork of https://gitlab.com/ericvh/docker-buildx-qemu
> it has been modified to not depend on a gitlab-ci template repository.
This Debian-based image allows you to easily build cross-platform images.
It's been tested with GitLab CI on gitlab.com, but it should work anywhere that docker-in-docker already works, and with a binfmt_misc enabled kernel.
## Example Usage
This GitLab example should give you an idea of how to use the image.
Dockerfile
```dockerfile
FROM alpine
RUN echo "Hello, my CPU architecture is $(uname -m)"
```
.gitlab-ci.yml
```yaml
variables:
CI_BUILD_ARCHS: "linux/arm/v7,linux/arm64,linux/amd64"
CI_BUILD_IMAGE: "registry.gitlab.com/ericvh/docker-buildx-qemu"
build:
image: $CI_BUILD_IMAGE
stage: build
services:
- name: docker:dind
entrypoint: ["env", "-u", "DOCKER_HOST"]
command: ["dockerd-entrypoint.sh"]
variables:
DOCKER_HOST: tcp://docker:2375/
DOCKER_DRIVER: overlay2
# See https://github.com/docker-library/docker/pull/166
DOCKER_TLS_CERTDIR: ""
retry: 2
before_script:
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
# Use docker-container driver to allow useful features (push/multi-platform)
- update-binfmts --enable # Important: Ensures execution of other binary formats is enabled in the kernel
- docker buildx create --driver docker-container --use
- docker buildx inspect --bootstrap
script:
- docker buildx ls
- docker buildx build --platform $CI_BUILD_ARCHS --progress plain --pull -t "$CI_REGISTRY_IMAGE" --push .
```
And the (partial) output:
```
#6 [linux/amd64 2/2] RUN echo "Hello, my CPU architecture is $(uname -m)"
#6 0.120 Hello, my CPU architecture is x86_64
#6 DONE 0.3s
#8 [linux/arm/v7 2/2] RUN echo "Hello, my CPU architecture is $(uname -m)"
#8 0.233 Hello, my CPU architecture is armv7l
#8 DONE 0.2s
```
</details>

25
dockerfile Normal file
View File

@ -0,0 +1,25 @@
FROM --platform=$TARGETPLATFORM debian:11.7-slim
ARG DEBIAN_FRONTEND=noninteractive
RUN apt-get update && apt-get install -y \
apt-transport-https \
ca-certificates \
curl \
git \
gnupg2 \
software-properties-common \
python3 \
python3-pip
RUN curl -fsSL https://download.docker.com/linux/debian/gpg | apt-key add - && \
add-apt-repository "deb https://download.docker.com/linux/debian $(lsb_release -cs) stable" && \
add-apt-repository "deb http://deb.debian.org/debian bullseye-backports main" && \
apt-get update && apt-get install -y \
docker-buildx-plugin \
docker-ce-cli \
binfmt-support=2.2.1-1+deb11u1 \
qemu-user-static=1:7.2+dfsg-7~bpo11+1

1
gitlab-ci Submodule

Submodule gitlab-ci added at 588956b27e

View File

@ -1,46 +0,0 @@
image: jonoh/docker-buildx-qemu
variables:
DOCKER_HOST: tcp://docker:2375/
PLATFORM: local
DOCKER_IMAGE_TAG: latest
DOCKER_PREBUILD_CMD: echo
services:
- docker:dind
.docker_before_script: &docker_before_script
- docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
- docker pull "$CI_REGISTRY_IMAGE" || true
- '[[ "$PLATFORM" != "local" ]] && update-binfmts --enable'
# Use docker-container driver to allow useful features (push/multi-platform)
- docker buildx create --driver docker-container --use
- docker buildx inspect --bootstrap
build:
stage: build
before_script: *docker_before_script
script:
- $DOCKER_PREBUILD_CMD
- docker buildx build
--pull
--cache-from "$CI_REGISTRY_IMAGE"
--platform "$PLATFORM"
-t "$CI_REGISTRY_IMAGE:$DOCKER_IMAGE_TAG"
--push $EXTRA_BUILD_ARGS .
only:
- master
build-unstable:
stage: build
before_script: *docker_before_script
script:
- $DOCKER_PREBUILD_CMD
- docker buildx build
--pull
--cache-from "$CI_REGISTRY_IMAGE"
--platform "$PLATFORM"
-t "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG"
--push $EXTRA_BUILD_ARGS .
except:
- master