scalafmt icon indicating copy to clipboard operation
scalafmt copied to clipboard

multi-architecture docker image

Open denisa opened this issue 1 year ago • 4 comments

please provide a docker image that works natively on amd64 and arm64 architecture.

Since the release of Apple’s m1-based macs, this architecture is more common and, while possible, executing amd64 image on them is not optimal

denisa avatar May 15 '23 04:05 denisa

hey, just gave a look at this issue out of curiosity. According to https://docs.docker.com/build/ci/github-actions/multi-platform/, this could be solved with just a line added here :

          platforms: linux/amd64,linux/arm64, darwin/amd64,darwin/arm64

Not sure if that does the trick (didn't test), but I thought my little research could be useful.

ag91 avatar Jul 09 '23 21:07 ag91

That’s probably not enough: this would copy the same binary built on GitHub onto all these images, eg they would all have the same scalafmt-linux-musl

denisa avatar Jul 12 '23 01:07 denisa

good point! It seems the scalafmt-macos is created already here. So I guess that may just need an if else in the Dockerfile to copy the right binary file (or even move them both?)

ag91 avatar Jul 12 '23 15:07 ag91

I’ve generally seen (and used) multi-phase docker images: a first phase builds the binary from scratch in a docker images, while a 2nd phase copes the binary on a clean linux base image, thus discarding all intermediate files…

https://github.com/denisa/clq/blob/main/build/docker/alpine/Dockerfile is an example for a simple golang app

denisa avatar Aug 06 '23 23:08 denisa