postgres-websockets icon indicating copy to clipboard operation
postgres-websockets copied to clipboard

Support multiple docker architectures

Open jamesmstone opened this issue 2 years ago • 3 comments

It would be great if we can support multiple architectures at the moment the published image is just (amd64)

I think this could now be achieved fairly easily using docker buildx , please see https://docs.docker.com/desktop/extensions-sdk/extensions/multi-arch/

If you are open to the idea, I am happy to make a PR adding this

jamesmstone avatar Aug 15 '22 06:08 jamesmstone

@jamesmstone that sounds like a reasonable improvement. Specially considering how arm has gained so much traction in the server space.

diogob avatar Aug 18 '22 17:08 diogob

Sounds good!

Ahh, this is actually a bit more complicated than I first thought. I hadn't realised there are actually two Dockerfiles.

One for the building the binary and one for building the environment

I still briefly tried with my original idea:

build-docker.sh

platforms="linux/amd64,linux/arm64,linux/arm"
docker buildx build --platform $platforms -f Dockerfile.build -t diogob/alpine-ghc .
stack --compiler ghc-8.8.3 --system-ghc --docker --docker-image=diogob/alpine-ghc install
docker buildx build --platform $platforms -t diogob/postgres-websockets .

But I don't think that will work, as (I think) stack assumes the host's architecture

jamesmstone avatar Aug 22 '22 00:08 jamesmstone

The only notes I can find on stack and docker are here https://docs.haskellstack.org/en/stable/docker_integration/, but that does not specify how to use build using a docker different docker architectures

And from docker's docs: https://docs.docker.com/desktop/multi-arch/#build-and-run-multi-architecture-images

I think the only way to run an image with a particular architecture is using the sha of the image

jamesmstone avatar Aug 22 '22 01:08 jamesmstone

@alnoki I was just reading this issue and thinking that you folks might be interested in upstreaming your docker image building. I would be willing to support that as long as the process is mostly automated. I am also not attached to Alpine and would be happy moving to Debian if it makes things easier.

If you are willing to help me build a plan on how to support the build for different architectures (and preferably if it is possible to keep the build scripts running on github) please let me know.

diogob avatar Oct 13 '23 14:10 diogob

@diogob Thanks for the tag here

We are not doing CI on ours (at least not yet), and so we don't have any images on Docker Hub etc.,. but we do ensure that any Docker images we create compile straight from source and to that extent that they are architecture-agnostic.

Here is the postgres-websockets image we ended up settling on FWIW: https://github.com/econia-labs/econia/blob/96b17a9/src/docker/api/Dockerfile.ws

If you're looking for more context it is part of our "Data Service Stack", a portable infrastructure microservice that we provide so anyone can run: https://econia.dev/off-chain/dss/data-service-stack

alnoki avatar Oct 13 '23 21:10 alnoki

Thanks @alnoki for the help and @jamesmstone for bringing the issue. As of 0.11.2.2 we have 2 architectures available on the docker imaage: linux/amd64 and linux/arm64.

diogob avatar Nov 13 '23 14:11 diogob