blueimp / aws-smtp-relay

SMTP server to relay emails via Amazon SES or Amazon Pinpoint using IAM roles.
MIT License
76 stars 34 forks source link

Added Dockerfiles for arm (32-bit) and arm64 (64-bit) architectures #6

Closed andrewmiskell closed 5 years ago

andrewmiskell commented 5 years ago

Allows for hub.docker.com's build infrastructure (which is x86_64 based) to properly compile images for arm and arm64 (i.e. Raspberry Pi type devices) architectures.

Similar to what I've done on my hub.docker.com account (https://hub.docker.com/r/andrewmiskell/aws-smtp-relay/tags), you can create a manifest file and you can publish a latest tag which will automatically pull in the appropriate architecture.

docker manifest create andrewmiskell/aws-smtp-relay:latest andrewmiskell/aws-smtp-relay:amd64 andrewmiskell/aws-smtp-relay:arm andrewmiskell/aws-smtp-relay:arm64

docker manifest annotate andrewmiskell/aws-smtp-relay:latest andrewmiskell/aws-smtp-relay:arm --os linux --arch arm

docker manifest annotate andrewmiskell/aws-smtp-relay:latest andrewmiskell/aws-smtp-relay:arm64 --os linux --arch arm64

docker manifest push andrewmiskell/aws-smtp-relay:latest

Personally, I just put them in a directory for dockerfile, but it may make more sense to you to call them Dockerfile (for amd64), Dockerfile.arm (for ARM32bit) and Dockerfile.arm64 (for ARM64bit).

andrewmiskell commented 5 years ago

On the manifest files, for completeness sake, you may want to explicitly annotate the amd64 image as well (although I think docker manifest assumes amd64/linux by default).

So the commands for creating the manifest would be the following (obviously substituting your DockerHub repo name).

docker manifest create andrewmiskell/aws-smtp-relay:latest andrewmiskell/aws-smtp-relay:amd64 andrewmiskell/aws-smtp-relay:arm andrewmiskell/aws-smtp-relay:arm64

docker manifest annotate andrewmiskell/aws-smtp-relay:latest andrewmiskell/aws-smtp-relay:amd64 --os linux --arch amd64

docker manifest annotate andrewmiskell/aws-smtp-relay:latest andrewmiskell/aws-smtp-relay:arm --os linux --arch arm

docker manifest annotate andrewmiskell/aws-smtp-relay:latest andrewmiskell/aws-smtp-relay:arm64 --os linux --arch arm64

docker manifest push andrewmiskell/aws-smtp-relay:latest

This would produce a manifest similar to one used by projects like PiHole which provide a manifest for amd64, arm and arm64 architectures as well.

blueimp commented 5 years ago

Thanks for your contribution @andrewmiskell.

I am very reluctant to add additional architecture builds though, especially ones that I don't have an environment to test with.

Therefore I've added ARG arguments that allow you to define the target arch via docker build --platform and --build-arg arguments, see: https://docs.docker.com/engine/reference/builder/#automatic-platform-args-in-the-global-scope

Hope that solves your use case.