diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 2e30af7..17da79b 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -5,7 +5,7 @@ include: ref: development file: - .gitlab-ci_common.yaml - - type/docker-image.gitlab-ci.yaml + - template/docker-image.gitlab-ci.yaml variables: @@ -17,7 +17,14 @@ variables: #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/386,linux/arm/v7,linux/arm/v6" + 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 + + + + diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index 4be7b83..0000000 --- a/Dockerfile +++ /dev/null @@ -1,37 +0,0 @@ -FROM debian - - - -RUN export DEBIAN_FRONTEND=noninteractive \ - && apt-get update && apt --fix-broken install \ - && apt install -y libc-bin locales-all - - - -RUN export DEBIAN_FRONTEND=noninteractive \ - && apt-get update && apt-get install -y \ - apt-transport-https \ - ca-certificates \ - curl \ - git \ - gnupg2 \ - software-properties-common \ - python3 \ - python3-pip || true - - -# Install Docker and qemu -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" && \ - apt-get update && apt-get install -y \ - docker-buildx-plugin \ - docker-ce-cli \ - binfmt-support \ - qemu-user-static || true - - -# 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 - -RUN echo "[DEBUG] why arm64 reports no docker 'which docker'=[$(which docker)]" \ No newline at end of file diff --git a/README.md b/README.md index 9bc153a..82f082d 100644 --- a/README.md +++ b/README.md @@ -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) ----
@@ -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). diff --git a/dockerfile b/dockerfile new file mode 100644 index 0000000..3302c17 --- /dev/null +++ b/dockerfile @@ -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 diff --git a/gitlab-ci b/gitlab-ci index 18a2808..588956b 160000 --- a/gitlab-ci +++ b/gitlab-ci @@ -1 +1 @@ -Subproject commit 18a280878799fe077efa0ed5b11bceedd53eb5c8 +Subproject commit 588956b27ec8973bf8a0ce39566f1ec07a0c2f6b