scalameta / scalafmt

Code formatter for Scala
http://scalameta.org/scalafmt
Apache License 2.0
1.43k stars 277 forks source link

multi-architecture docker image #3542

Open denisa opened 1 year ago

denisa commented 1 year ago

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

ag91 commented 1 year ago

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.

denisa commented 1 year ago

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

ag91 commented 1 year ago

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?)

denisa commented 1 year ago

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