-
Notifications
You must be signed in to change notification settings - Fork 601
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
Enable multi-architecture docker image builds #327
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Previously, the Dockerfile downloaded a 'docker-gen' binary during build time. This caused a problem as it hard-coded the amd64 architecture for the image. This commit updates the Dockerfile to build the docker-gen executable from source instead of downloading a binary. This updated Dockerfile uses a multi-stage build [1]. The first stage downloads a source tarball from github and produces a binary out of it. The second stage corresponds to the old Dockerfile, with the sole change being that is fetches the binary from the first stage instead of GitHub. This has the advantage that the build process no longer assumes a certain architecture and enables building the image for any architecture that both the golang and alpine base images support. [1] https://docs.docker.com/develop/develop-images/multistage-build/
The previous version of the Dockerfile made use of version 0.7.3. However because of changes in dependencies, this can no longer be compiled from source. To fix this regression, this commit updates the version used to 0.7.4.
tkw1536
added a commit
to KWARC/nginx-proxy
that referenced
this pull request
Jul 13, 2020
Previously, the Dockerfile downloaded 'docker-gen' and 'forego' binaries during build time. This caused a problem as it hard-coded the amd64 architecture for the images. This commit updates both 'Dockerfile' and 'Dockerfile.alpine' to build the `forego` and `docker-gen` executables from scratch instead of downloading binaries directly. This is achieved using multi-stage builds [1]. Two seperate stages first build the binaries, and are then copied over to the final stage. The advantage of this change is two-fold: First, it enables building this image on architectures other than amd64. Secondly it adds trust by not adding external binaries to the docker image. This modified version passes the test both a linux desktop (amd64) as well as a raspberry pi (armv7) with some caveats: - On armv7, a modified version of the `jwilder/docker-gen` image is required. See a seperate PR at [2]. - The 'test_dhparam_is_generated_if_missing' test fails. This also doesn't currently pass on master. [1] https://docs.docker.com/develop/develop-images/multistage-build/ [2] nginx-proxy/docker-gen#327
tkw1536
added a commit
to KWARC/nginx-proxy
that referenced
this pull request
Oct 11, 2020
Previously, the Dockerfile downloaded 'docker-gen' and 'forego' binaries during build time. This caused a problem as it hard-coded the amd64 architecture for the images. This commit updates both 'Dockerfile' and 'Dockerfile.alpine' to build the `forego` and `docker-gen` executables from scratch instead of downloading binaries directly. This is achieved using multi-stage builds [1]. Two seperate stages first build the binaries, and are then copied over to the final stage. The advantage of this change is two-fold: First, it enables building this image on architectures other than amd64. Secondly it adds trust by not adding external binaries to the docker image. This modified version passes the test both a linux desktop (amd64) as well as a raspberry pi (armv7) with some caveats: - On armv7, a modified version of the `jwilder/docker-gen` image is required. See a seperate PR at [2]. - The 'test_dhparam_is_generated_if_missing' test fails. This also doesn't currently pass on master. [1] https://docs.docker.com/develop/develop-images/multistage-build/ [2] nginx-proxy/docker-gen#327
tkw1536
added a commit
to KWARC/nginx-proxy
that referenced
this pull request
Jan 10, 2021
Previously, the Dockerfile downloaded 'docker-gen' and 'forego' binaries during build time. This caused a problem as it hard-coded the amd64 architecture for the images. This commit updates both 'Dockerfile' and 'Dockerfile.alpine' to build the `forego` and `docker-gen` executables from scratch instead of downloading binaries directly. This is achieved using multi-stage builds [1]. Two seperate stages first build the binaries, and are then copied over to the final stage. The advantage of this change is two-fold: First, it enables building this image on architectures other than amd64. Secondly it adds trust by not adding external binaries to the docker image. This modified version passes the test both a linux desktop (amd64) as well as a raspberry pi (armv7) with some caveats: - On armv7, a modified version of the `jwilder/docker-gen` image is required. See a seperate PR at [2]. - The 'test_dhparam_is_generated_if_missing' test fails. This also doesn't currently pass on master. [1] https://docs.docker.com/develop/develop-images/multistage-build/ [2] nginx-proxy/docker-gen#327
tkw1536
added a commit
to KWARC/nginx-proxy
that referenced
this pull request
Feb 6, 2021
Previously, the Dockerfile downloaded 'docker-gen' and 'forego' binaries during build time. This caused a problem as it hard-coded the amd64 architecture for the images. This commit updates both 'Dockerfile' and 'Dockerfile.alpine' to build the `forego` and `docker-gen` executables from scratch instead of downloading binaries directly. This is achieved using multi-stage builds [1]. Two seperate stages first build the binaries, and are then copied over to the final stage. The advantage of this change is two-fold: First, it enables building this image on architectures other than amd64. Secondly it adds trust by not adding external binaries to the docker image. This modified version passes the test both a linux desktop (amd64) as well as a raspberry pi (armv7) with some caveats: - On armv7, a modified version of the `jwilder/docker-gen` image is required. See a seperate PR at [2]. - The 'test_dhparam_is_generated_if_missing' test fails. This also doesn't currently pass on master. [1] https://docs.docker.com/develop/develop-images/multistage-build/ [2] nginx-proxy/docker-gen#327
tkw1536
added a commit
to KWARC/nginx-proxy
that referenced
this pull request
Mar 21, 2021
Previously, the Dockerfile downloaded 'docker-gen' and 'forego' binaries during build time. This caused a problem as it hard-coded the amd64 architecture for the images. This commit updates both 'Dockerfile' and 'Dockerfile.alpine' to build the `forego` and `docker-gen` executables from scratch instead of downloading binaries directly. This is achieved using multi-stage builds [1]. Two seperate stages first build the binaries, and are then copied over to the final stage. The advantage of this change is two-fold: First, it enables building this image on architectures other than amd64. Secondly it adds trust by not adding external binaries to the docker image. This modified version passes the test both a linux desktop (amd64) as well as a raspberry pi (armv7) with some caveats: - On armv7, a modified version of the `jwilder/docker-gen` image is required. See a seperate PR at [2]. - The 'test_dhparam_is_generated_if_missing' test fails. This also doesn't currently pass on master. [1] https://docs.docker.com/develop/develop-images/multistage-build/ [2] nginx-proxy/docker-gen#327
jwilder
approved these changes
Apr 3, 2021
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Previously, the Dockerfile downloaded a 'docker-gen' binary during build time. This caused a problem as it hard-coded the
amd64
architecture for the image.This PR updates the Dockerfile to build the
docker-gen
executable from source instead of downloading a binary. This updated Dockerfile uses a multi-stage build [1].The first stage downloads a source tarball from GitHub and produces a binary out of it. The second stage corresponds to the old Dockerfile, with the sole change being that is fetches the binary from the first stage instead of GitHub.
This has the advantage that the build process no longer assumes a certain architecture and enables building the image for any architecture that both the golang and alpine base images support.
I've tested building this modified Dockerfile on both a linux desktop (
amd64
) and a raspberry pi (armv7
). I've also used the built image to successfully test a modified architecture independent variant of [2] successfully, I will make a similar PR there soon as well.Together with actually publishing multi-architecture images to DockerHub this PR fixes #304 and #318.
This PR also bumps the version being built to 0.7.4, as 0.7.3 can no longer be compiled from source.
[1] https://docs.docker.com/develop/develop-images/multistage-build/
[2] https://github.com/nginx-proxy/nginx-proxy