wader / postfix-relay

Postfix SMTP relay docker image

Home Page:https://hub.docker.com/r/mwader/postfix-relay/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Provide multi-platform Docker images

forzagreen opened this issue · comments

commented

The Docker image in Docker Hub mwader/postfix-relay currently supports only OS/arch of type linux/amd64 .
It would be great to support multiple architectures (=platforms), in particular linux/arm64 , as ARM processors are widely used.

How to reproduce

If you run in an ARM machine:

$ dpkg --print-architecture
arm64

You get the following error:

$ docker run -it --rm mwader/postfix-relay:latest bash

WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested
standard_init_linux.go:219: exec user process caused: exec format error

Usecases

  • My usecase is to deploy the container in a RaspberryPi, which has an ARM processor.
  • Any other ARM machine.

Suggested solution

You can use buildx. It can build and push a multi-platform image without modifying the Dockerfile.
It integrates very well with CI/CD pipelines:
Example of GitHub Actions: https://github.com/marketplace/actions/build-and-push-docker-images#multi-platform-image

Tests

I tested a multi-architecture build with buildx, following the steps here: https://docs.docker.com/docker-for-mac/multi-arch/

$ docker buildx create --name mybuilder
mybuilder
$ docker buildx use mybuilder
$ docker buildx build --platform linux/amd64,linux/arm64 -t forzagreen/postfix-relay:multi --push .

The resulting image is here: forzagreen/postfix-relay:multi
I tested in both amd64 and arm64.
Docker pulls the correct image based on the machine architecture.

Hi! yes would like to do this also for this image and some other images that I have. Thanks for the links and suggestion, i guess I will move image building from docker hub to github actions somehow, seems to be the most flexible.

Hi again, could you try again now? now the image is built for platforms linux/amd64, linux/arm/v7 and linux/arm64, same as official debian and ubuntu images minus ppc and s390.

Workflow is here https://github.com/wader/postfix-relay/blob/master/.github/workflows/ci.yml there were some minor issues that got solved but might be done better:

  • How to map master tag to latest tag, now done with if
  • How to update docker hub description, now done with a dummy build in docker hub (action to do it does not work with 2FA peter-evans/dockerhub-description#10)

Let me know if you have suggestions

And feel free to close issue if you think things seem ok!

commented

Thank you !
I tested with the new image in my Raspberry Pi (with arm64 architecture). It works great 👍

For suggestions, I have some ideas:

  • Add releases and tags to provide fixed versions, for both Github code and the image in Docker Hub (like mwader/postfix-relay:1.0.0 )
  • For all push and pull requests: build image without push
  • Only for tags (and maybe master branch too): build and push image.

I will try to test it and start a PR.

Great!

Tags could be a good idea to make it possible to stay at a version but don't think i would want to maintain some kind of version semver compatilbity, but of course i already try hard not to break things for the latest tag.

I think it should do a test builds for pull requests now