Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Docker buildx build workflow #116

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

npawelek
Copy link

@npawelek npawelek commented Apr 24, 2020

This change will use docker buildx build to create a multi-architecture
container (386, amd64, arm/v6, arm/v7, arm64, ppc64le, s390x) for the master
branch and pushed tags. If a tag is pushed, the version will be tagged along
with latest. If no tag is pushed, then only the latest tag will be updated.

The only piece of information that you'll likely need to add is a secret for
DOCKER_PASSWORD using a Docker Access Token. No credential artifacts are left
behind in this process. The docker login information is added to
.docker/config.json which is deleted in the last task.

In my testing, overall container build time is around 15 minutes. Feel free to
change as needed, this should be a good starting point.

Closes #112

This change will use Docker buildx to create a multi-architecture
container (386, amd64, arm/v6, arm/v7, arm64, ppc64le, s390x) for the
master branch and pushed tags. If a tag is pushed, the version will be
tagged along with latest. If no tag is pushed, then only the latest tag
will be updated.
@SuperSandro2000
Copy link
Contributor

Maybe we should add .github to https://github.com/thomseddon/traefik-forward-auth/blob/master/.dockerignore

@IslamAlam
Copy link

@npawelek This is a great starting point for multi-arch build.

It would be great to integrate the following flags (under the PR) for selecting the arch for the build.
Please let me know what you think.
https://github.com/thomseddon/traefik-forward-auth/pull/117/files#diff-3254677a7917c6c01f55212f86c57fbfR12-R26

@thomseddon
Copy link
Owner

At the moment the git tag v3.4.5 will create tagged builds on docker hub for 3, 3.4, 3.4.5 and latest - which I think is desirable for people wanting to choose how tightly they want to lock their image.

This action has a tag_semver option which seems to look like what we need: https://github.com/marketplace/actions/publish-docker (There may be other actions that also achieve this?)

Otherwise I'm 👍 for this

@IslamAlam I have responded in your PR, what's notable here is that with this change, the GOARCH env var has actually been removed from the Dockerfile and the platform is passed as a parameter to buildx. My understanding is GOARCH will always default to whatever platform your building on, so this would actually restore the expected behaviour of someone building the Dockefile when not on amd64

@thomseddon thomseddon added the enhancement New feature or request label Apr 30, 2020
@SuperSandro2000
Copy link
Contributor

This is how I tag one of my images:

sudo --preserve-env=DOCKER_BUILDKIT,DOCKER_CLI_EXPERIMENTAL,COMPOSE_DOCKER_CLI_BUILD,HOME,PWD DOCKER_CLI_EXPERIMENTAL=enabled docker buildx build --platform linux/amd64 --platform linux/arm/v7 --platform linux/arm64 -t docker.io/supersandro2000/zeronet:latest -t docker.io/supersandro2000/zeronet:0 -t docker.io/supersandro2000/zeronet:0.7 -t docker.io/supersandro2000/zeronet:0.7.1 -t docker.io/supersandro2000/zeronet:0.7.1-r4478 --build-arg SHA=f3a839f422afd50f5bf8f17d83a8807571bc1dfe --build-arg BUILD_DATE=2020-04-30 --build-arg REVISION=0b413e1 --build-arg VERSION=0.7.1-r4478 --pull --push  .

Buildx is quite smart and can take multiple tags which I think we should utilize here.

I generate the version numbers with the following Makefile line

TAGS ?= latest $(shell echo $(VERSION) | cut -f1 -d".") $(shell echo $(VERSION) | awk -F '[.-]' '{print $$1"."$$2}') $(shell echo $(VERSION) | awk -F '[.-]' '{print $$1"."$$2"."$$3}') $(VERSION)

@oscrx
Copy link

oscrx commented Jun 22, 2022

I think this workflow can be cleaned up with the latest versions of Github actions from Docker
(migrated from crazymax)
Example here: https://github.com/ThioJoe/YT-Spammer-Purge/blob/main/.github/workflows/docker-build.yml#L17

@StefanSchoof
Copy link

I created an alternate approach at #378

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Multi-architecture image for non-homogenous environments
6 participants