postgrest icon indicating copy to clipboard operation
postgrest copied to clipboard

Arm64 docker image size is far more large than amd64

Open jingsam opened this issue 2 years ago • 4 comments

Environment

  • PostgreSQL version: 12
  • PostgREST version: v9.0.1
  • Operating system: macOS 12.5

Description of issue

The docker image size of arm64 is 21 times bigger than amd64.

version os/arch size
v9.0.1 linux/amd64 4.37MB
v9.0.1 linux/amd64 93.72MB

image

I checked the Dockerfile for arm64. I think it is not optimized.

https://github.com/PostgREST/postgrest/blob/92d00749a35fddd72000d383d7bb6a582f87d1ed/.github/scripts/arm/docker-env/Dockerfile#L1-L16

(Expected behavior vs actual behavior)

(Steps to reproduce: Include a minimal SQL definition plus how you make the request to PostgREST and the response body)

jingsam avatar Aug 06 '22 10:08 jingsam

Yes, the amd64 image is very small because it is built using nix, generating a static binary that can be executed on a minimal docker image. Unfortunately, we cannot do that on arm64 architectures as it's not fully supported there. Our solution is to build the binary using cabal (even stack isn't fully supported) on an arm server and then copy that binary to the docker image with the needed libraries installed. Until the architecture does not support to build static binaries we cannot make a minimal docker image for it.

laurenceisla avatar Aug 06 '22 16:08 laurenceisla

A while back I experimented with cross-compiling from within our nix setup at https://github.com/wolfgangwalther/postgrest/pull/89/files. I didn't get very far, but I think #2332 might go a long way to support this down the stretch.

Once we support cross compiling from within nix, we could simplify our CI setup a lot, support more platforms and provide minimal docker images for all of them. That would be a huge win.

wolfgangwalther avatar Aug 11 '22 16:08 wolfgangwalther