Merge branch 'genesis' into 'development'

refactor: update project

See merge request nofusscomputing/projects/docker-buildx-qemu!1
This commit is contained in:
2023-05-15 02:20:53 +00:00
9 changed files with 118 additions and 235 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.0.1

View File

@ -1,124 +1,23 @@
# 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
- type/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"
build:arm64:
extends: .build
only:
variables:
- $CI_BUILD_ARM64
except:
variables:
- $CI_BUILDX_ARCHS
tags:
- arm64
#JOB_STOP_CONVENTIONAL_COMMITS: 'disable for testing'
#JOB_STOP_GIT_PUSH_MIRROR: 'disable for testing'
#JOB_STOP_GITLAB_RELEASE: 'disable for testing'
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
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_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

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

View File

@ -1,26 +1,37 @@
FROM debian
# Install Docker and qemu
# TODO Use docker stable once it properly supports buildx
RUN apt-get update && apt-get install -y \
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 && \
curl -fsSL https://download.docker.com/linux/debian/gpg | apt-key add - && \
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
qemu-user-static || true
# 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
RUN echo "[DEBUG] why arm64 reports no docker 'which docker'=[$(which docker)]"

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.

57
README.md Normal file
View File

@ -0,0 +1,57 @@
<div align="center" width="100%">
# No Fuss Computing - Docker Buildx with QEMU
<br>
![Project Status - Active](https://img.shields.io/badge/Project%20Status-Active-green?logo=gitlab&style=plastic)
<br>
![Gitlab forks count](https://img.shields.io/badge/dynamic/json?label=Forks&query=%24.forks_count&url=https%3A%2F%2Fgitlab.com%2Fapi%2Fv4%2Fprojects%2F45926238%2F&color=ff782e&logo=gitlab&style=plastic) ![Gitlab stars](https://img.shields.io/badge/dynamic/json?label=Stars&query=%24.star_count&url=https%3A%2F%2Fgitlab.com%2Fapi%2Fv4%2Fprojects%2F45926238%2F&color=ff782e&logo=gitlab&style=plastic) [![Open Issues](https://img.shields.io/badge/dynamic/json?color=ff782e&logo=gitlab&style=plastic&label=Open%20Issues&query=%24.statistics.counts.opened&url=https%3A%2F%2Fgitlab.com%2Fapi%2Fv4%2Fprojects%2F45926238%2Fissues_statistics)](https://gitlab.com/nofusscomputing/projects/docker-buildx-qemu/-/issues)
![GitHub forks](https://img.shields.io/github/forks/NofussComputing/docker-buildx-qemu?logo=github&style=plastic&color=000000&labell=Forks) ![GitHub stars](https://img.shields.io/github/stars/NofussComputing/docker-buildx-qemu?color=000000&logo=github&style=plastic) ![Github Watchers](https://img.shields.io/github/watchers/NofussComputing/docker-buildx-qemu?color=000000&label=Watchers&logo=github&style=plastic)
<br>
This project is hosted on [gitlab](https://gitlab.com/nofusscomputing/projects/docker-buildx-qemu) and has a read-only copy hosted on [Github](https://github.com/NofussComputing/docker-buildx-qemu).
----
**Stable Branch**
![Gitlab build status - stable](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%3Dmaster&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%2Fmaster%2F.cz.yaml)
----
**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)
----
<br>
</div>
links:
- [Issues](https://gitlab.com/nofusscomputing/projects/docker-buildx-qemu/-/issues)
- [Merge Requests (Pull Requests)](https://gitlab.com/nofusscomputing/projects/docker-buildx-qemu/-/merge_requests)
> 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!!
## Contributing
All contributions for this project must conducted from [Gitlab](https://gitlab.com/nofusscomputing/projects/docker-buildx-qemu).
For further details on contributing please refer to the [contribution guide](CONTRIBUTING.md).
## Other
This repo is release under this [license](LICENSE)

1
gitlab-ci Submodule

Submodule gitlab-ci added at 18a2808787

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

View File

@ -1,60 +0,0 @@
# 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
```