Postgrest: Docker image compatible with ARM: is that possible?

Created on 20 May 2018  路  45Comments  路  Source: PostgREST/postgrest

Environment

  • PostgreSQL version: postgres:10.4
  • PostgREST version: v0.5.0.0
  • Operating system: Raspbian GNU/Linux 9 (stretch)

pi@raspberrypi:~ $ uname -a
Linux raspberrypi 4.14.34-v7+ #1110 SMP Mon Apr 16 15:18:51 BST 2018 armv7l GNU/Linux
pi@raspberrypi:~ $ cat /etc/os-release
PRETTY_NAME="Raspbian GNU/Linux 9 (stretch)"
NAME="Raspbian GNU/Linux"
VERSION_ID="9"
VERSION="9 (stretch)"
ID=raspbian
ID_LIKE=debian
HOME_URL="http://www.raspbian.org/"
SUPPORT_URL="http://www.raspbian.org/RaspbianForums"
BUG_REPORT_URL="http://www.raspbian.org/RaspbianBugs"

Description of issue

Probably related to #846, but I would like to ask about the possibility of a Docker image ready for ARM processors. So far I think the PostgREST Docker image is not compatible:

pi@raspberrypi:~ $ docker pull postgrest/postgrest
Using default tag: latest
latest: Pulling from postgrest/postgrest
Digest: sha256:8c40ba14f6400a51be1ed78f83f472132a96ab955fe627ca385286378dd3f88b
Status: Image is up to date for postgrest/postgrest:latest
pi@raspberrypi:~ $ docker run postgrest/postgrest


standard_init_linux.go:190: exec user process caused "exec format error"

Also I see only amd64 in the image inspector:

pi@raspberrypi:~ $ docker inspect postgrest/postgrest | grep Architecture
        "Architecture": "amd64",

Is this possible and in the radar for short term releases? Is there someway I could help in this particular issue?

ci

Most helpful comment

@hughjfchen Could you please share the build details?
I have a scaleway Arm64 server and I could setup a CI build on it.

I've been building the postgrest docker images for aarch64 recently. You can use it by pulling the images from my docker.io repos:
docker pull hughjfchen/hughjfchen:postgrest-aarch64-5.2.0
or:
docker pull hughjfchen/hughjfchen:postgrest-aarch64-6.0.2

If you want to play around with my build process, I have a github repos which builds the above images with my home-made shell-script-based CI/CD framework. You can build on your scaleway arm64 instance with following steps:

  1. make sure you have an account which can use sudo without password
  2. clone my github repos with the command: git clone https://github.com/hughjfchen/postgrest-docker
    3.build the images with one of the following commands:
    postgrest-docker/postgrest-6.0/DevOps/scaleway/test/cb.sh, or
    postgrest-docker/postgrest-5.2/DevOps/scaleway/test/cb.sh
    4.once finished, you can find the nix derivation result under the postgrest-docker/postgrest-6.0 or postgrest-docker/postgrest-5.2 directory respectively.

All 45 comments

Edit: Prefer the binary in https://github.com/PostgREST/postgrest/issues/1117#issuecomment-407791111, this one presented some errors when tested on a Rasberry Pi.

I've uploaded a PostgREST binary for ARMv7 here https://github.com/steve-chavez/postgrest/releases/download/v0.5.0.0/postgrest-v0.5.0.0-debian-armv7.tar.xz, maybe you can test it so I can later see how to create a docker image for that and make it an official release.

If you'd like to you can also build your own docker image with that binary by following this https://github.com/PostgREST/postgrest/blob/master/docker/Dockerfile.

Let me know how it goes, I don't own an ARM device so what I did was to use qemu and docker to build the binary, basically:

docker run --rm --privileged multiarch/qemu-user-static:register
docker run -it --rm multiarch/debian-debootstrap:armhf-stretch

Hey @steve-chavez,

Didn't work for me, I tried to build docker image with that binary, but, didn't work, can you help me?

I can see arm in the image inspector:

pi@raspberrypi:~/ $ docker inspect 6958 | grep Architecture
        "Architecture": "arm",

But my container log is:

pi@raspberrypi:~/ $ docker logs 6366
   /bin/sh: 1: exec: postgrest: not found
   /bin/sh: 1: exec: postgrest: not found

Maybe the postgrest it's differente architecture?

I changed this line in Dockerfile:

    curl -SLO https://github.com/steve-chavez/postgrest/releases/download/v0.5.0.0/postgrest-v0.5.0.0-debian-armv7.tar.xz && \

@nicolastarzia Maybe you're missing a change to this line https://github.com/PostgREST/postgrest/blob/f6c1ff810e92321f2cd522058d5c6fd74cb64226/docker/Dockerfile#L17.

It should be like tar -xJvf postgrest-v0.5.0.0-debian-armv7.tar.xz && \.

The binary I built has this file output:

ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux-armhf.so.3, for GNU/Linux 3.2.0, BuildID[sha1]=6a252f9ae1e4c1025e70f773f47d1607ff68ef1d, stripped

Sorry, but I changed this line too..

The log for docker build:

pi@raspberrypi:~/PostGrest $ docker build . -t postgrest:arm
Sending build context to Docker daemon  4.096kB
Step 1/7 : FROM debian:jessie
 ---> a7c226d6ce25
Step 2/7 : RUN apt-get -qq update &&     apt-get -qq install -y --no-install-recommends libpq5 &&     apt-get -qq clean &&     rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
 ---> Running in 9295b09e1202
debconf: delaying package configuration, since apt-utils is not installed
Selecting previously unselected package libssl1.0.0:armel.
(Reading database ... 7619 files and directories currently installed.)
Preparing to unpack .../libssl1.0.0_1.0.1t-1+deb8u8_armel.deb ...
Unpacking libssl1.0.0:armel (1.0.1t-1+deb8u8) ...
Selecting previously unselected package libkeyutils1:armel.
Preparing to unpack .../libkeyutils1_1.5.9-5+b1_armel.deb ...
Unpacking libkeyutils1:armel (1.5.9-5+b1) ...
Selecting previously unselected package libkrb5support0:armel.
Preparing to unpack .../libkrb5support0_1.12.1+dfsg-19+deb8u4_armel.deb ...
Unpacking libkrb5support0:armel (1.12.1+dfsg-19+deb8u4) ...
Selecting previously unselected package libk5crypto3:armel.
Preparing to unpack .../libk5crypto3_1.12.1+dfsg-19+deb8u4_armel.deb ...
Unpacking libk5crypto3:armel (1.12.1+dfsg-19+deb8u4) ...
Selecting previously unselected package libkrb5-3:armel.
Preparing to unpack .../libkrb5-3_1.12.1+dfsg-19+deb8u4_armel.deb ...
Unpacking libkrb5-3:armel (1.12.1+dfsg-19+deb8u4) ...
Selecting previously unselected package libgssapi-krb5-2:armel.
Preparing to unpack .../libgssapi-krb5-2_1.12.1+dfsg-19+deb8u4_armel.deb ...
Unpacking libgssapi-krb5-2:armel (1.12.1+dfsg-19+deb8u4) ...
Selecting previously unselected package libsasl2-modules-db:armel.
Preparing to unpack .../libsasl2-modules-db_2.1.26.dfsg1-13+deb8u1_armel.deb ...
Unpacking libsasl2-modules-db:armel (2.1.26.dfsg1-13+deb8u1) ...
Selecting previously unselected package libsasl2-2:armel.
Preparing to unpack .../libsasl2-2_2.1.26.dfsg1-13+deb8u1_armel.deb ...
Unpacking libsasl2-2:armel (2.1.26.dfsg1-13+deb8u1) ...
Selecting previously unselected package libldap-2.4-2:armel.
Preparing to unpack .../libldap-2.4-2_2.4.40+dfsg-1+deb8u3_armel.deb ...
Unpacking libldap-2.4-2:armel (2.4.40+dfsg-1+deb8u3) ...
Selecting previously unselected package libpq5:armel.
Preparing to unpack .../libpq5_9.4.15-0+deb8u1_armel.deb ...
Unpacking libpq5:armel (9.4.15-0+deb8u1) ...
Setting up libssl1.0.0:armel (1.0.1t-1+deb8u8) ...
debconf: unable to initialize frontend: Dialog
debconf: (TERM is not set, so the dialog frontend is not usable.)
debconf: falling back to frontend: Readline
debconf: unable to initialize frontend: Readline
debconf: (Can't locate Term/ReadLine.pm in @INC (you may need to install the Term::ReadLine module) (@INC contains: /etc/perl /usr/local/lib/arm-linux-gnueabi/perl/5.20.2 /usr/local/share/perl/5.20.2 /usr/lib/arm-linux-gnueabi/perl5/5.20 /usr/share/perl5 /usr/lib/arm-linux-gnueabi/perl/5.20 /usr/share/perl/5.20 /usr/local/lib/site_perl .) at /usr/share/perl5/Debconf/FrontEnd/Readline.pm line 7.)
debconf: falling back to frontend: Teletype
Setting up libkeyutils1:armel (1.5.9-5+b1) ...
Setting up libkrb5support0:armel (1.12.1+dfsg-19+deb8u4) ...
Setting up libk5crypto3:armel (1.12.1+dfsg-19+deb8u4) ...
Setting up libkrb5-3:armel (1.12.1+dfsg-19+deb8u4) ...
Setting up libgssapi-krb5-2:armel (1.12.1+dfsg-19+deb8u4) ...
Setting up libsasl2-modules-db:armel (2.1.26.dfsg1-13+deb8u1) ...
Setting up libsasl2-2:armel (2.1.26.dfsg1-13+deb8u1) ...
Setting up libldap-2.4-2:armel (2.4.40+dfsg-1+deb8u3) ...
Setting up libpq5:armel (9.4.15-0+deb8u1) ...
Processing triggers for libc-bin (2.19-18+deb8u10) ...
Removing intermediate container 9295b09e1202
 ---> 42991d12b687
Step 3/7 : RUN BUILD_DEPS="curl ca-certificates xz-utils" &&     apt-get -qq update &&     apt-get -qq install -y --no-install-recommends $BUILD_DEPS &&     cd /tmp &&     curl -SLO https://github.com/steve-chavez/postgrest/releases/download/v0.5.0.0/postgrest-v0.5.0.0-debian-armv7.tar.xz &&     tar -xJvf postgrest-v0.5.0.0-debian-armv7.tar.xz &&     mv postgrest /usr/local/bin/postgrest &&     cd / &&     apt-get -qq purge --auto-remove -y $BUILD_DEPS &&     apt-get -qq clean &&     rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
 ---> Running in e1ec061dab78
debconf: delaying package configuration, since apt-utils is not installed
Selecting previously unselected package libidn11:armel.
(Reading database ... 7729 files and directories currently installed.)
Preparing to unpack .../libidn11_1.29-1+deb8u2_armel.deb ...
Unpacking libidn11:armel (1.29-1+deb8u2) ...
Selecting previously unselected package librtmp1:armel.
Preparing to unpack .../librtmp1_2.4+20150115.gita107cef-1+deb8u1_armel.deb ...
Unpacking librtmp1:armel (2.4+20150115.gita107cef-1+deb8u1) ...
Selecting previously unselected package libssh2-1:armel.
Preparing to unpack .../libssh2-1_1.4.3-4.1+deb8u1_armel.deb ...
Unpacking libssh2-1:armel (1.4.3-4.1+deb8u1) ...
Selecting previously unselected package libcurl3:armel.
Preparing to unpack .../libcurl3_7.38.0-4+deb8u11_armel.deb ...
Unpacking libcurl3:armel (7.38.0-4+deb8u11) ...
Selecting previously unselected package xz-utils.
Preparing to unpack .../xz-utils_5.1.1alpha+20120614-2+b3_armel.deb ...
Unpacking xz-utils (5.1.1alpha+20120614-2+b3) ...
Selecting previously unselected package openssl.
Preparing to unpack .../openssl_1.0.1t-1+deb8u8_armel.deb ...
Unpacking openssl (1.0.1t-1+deb8u8) ...
Selecting previously unselected package ca-certificates.
Preparing to unpack .../ca-certificates_20141019+deb8u3_all.deb ...
Unpacking ca-certificates (20141019+deb8u3) ...
Selecting previously unselected package curl.
Preparing to unpack .../curl_7.38.0-4+deb8u11_armel.deb ...
Unpacking curl (7.38.0-4+deb8u11) ...
Setting up libidn11:armel (1.29-1+deb8u2) ...
Setting up librtmp1:armel (2.4+20150115.gita107cef-1+deb8u1) ...
Setting up libssh2-1:armel (1.4.3-4.1+deb8u1) ...
Setting up libcurl3:armel (7.38.0-4+deb8u11) ...
Setting up xz-utils (5.1.1alpha+20120614-2+b3) ...
update-alternatives: using /usr/bin/xz to provide /usr/bin/lzma (lzma) in auto mode
Setting up openssl (1.0.1t-1+deb8u8) ...
Setting up ca-certificates (20141019+deb8u3) ...
debconf: unable to initialize frontend: Dialog
debconf: (TERM is not set, so the dialog frontend is not usable.)
debconf: falling back to frontend: Readline
debconf: unable to initialize frontend: Readline
debconf: (Can't locate Term/ReadLine.pm in @INC (you may need to install the Term::ReadLine module) (@INC contains: /etc/perl /usr/local/lib/arm-linux-gnueabi/perl/5.20.2 /usr/local/share/perl/5.20.2 /usr/lib/arm-linux-gnueabi/perl5/5.20 /usr/share/perl5 /usr/lib/arm-linux-gnueabi/perl/5.20 /usr/share/perl/5.20 /usr/local/lib/site_perl .) at /usr/share/perl5/Debconf/FrontEnd/Readline.pm line 7.)
debconf: falling back to frontend: Teletype
Updating certificates in /etc/ssl/certs... 174 added, 0 removed; done.
Setting up curl (7.38.0-4+deb8u11) ...
Processing triggers for libc-bin (2.19-18+deb8u10) ...
Processing triggers for ca-certificates (20141019+deb8u3) ...
Updating certificates in /etc/ssl/certs... 0 added, 0 removed; done.
Running hooks in /etc/ca-certificates/update.d....done.
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   628    0   628    0     0    904      0 --:--:-- --:--:-- --:--:--   906
100 7944k  100 7944k    0     0   193k      0  0:00:40  0:00:40 --:--:--  226k
postgrest
(Reading database ... 8113 files and directories currently installed.)
Removing ca-certificates (20141019+deb8u3) ...
Removing dangling symlinks from /etc/ssl/certs... done.
Purging configuration files for ca-certificates (20141019+deb8u3) ...
debconf: unable to initialize frontend: Dialog
debconf: (TERM is not set, so the dialog frontend is not usable.)
debconf: falling back to frontend: Readline
debconf: unable to initialize frontend: Readline
debconf: (Can't locate Term/ReadLine.pm in @INC (you may need to install the Term::ReadLine module) (@INC contains: /etc/perl /usr/local/lib/arm-linux-gnueabi/perl/5.20.2 /usr/local/share/perl/5.20.2 /usr/lib/arm-linux-gnueabi/perl5/5.20 /usr/share/perl5 /usr/lib/arm-linux-gnueabi/perl/5.20 /usr/share/perl/5.20 /usr/local/lib/site_perl .) at /usr/share/perl5/Debconf/FrontEnd/Readline.pm line 7.)
debconf: falling back to frontend: Teletype
Removing dangling symlinks from /etc/ssl/certs... done.
Removing curl (7.38.0-4+deb8u11) ...
Removing libcurl3:armel (7.38.0-4+deb8u11) ...
Purging configuration files for libcurl3:armel (7.38.0-4+deb8u11) ...
Removing libidn11:armel (1.29-1+deb8u2) ...
Purging configuration files for libidn11:armel (1.29-1+deb8u2) ...
Removing librtmp1:armel (2.4+20150115.gita107cef-1+deb8u1) ...
Purging configuration files for librtmp1:armel (2.4+20150115.gita107cef-1+deb8u1) ...
Removing libssh2-1:armel (1.4.3-4.1+deb8u1) ...
Purging configuration files for libssh2-1:armel (1.4.3-4.1+deb8u1) ...
Removing openssl (1.0.1t-1+deb8u8) ...
Purging configuration files for openssl (1.0.1t-1+deb8u8) ...
Removing xz-utils (5.1.1alpha+20120614-2+b3) ...
Processing triggers for libc-bin (2.19-18+deb8u10) ...
Removing intermediate container e1ec061dab78
 ---> f5d64c7d3062
Step 4/7 : COPY postgrest.conf /etc/postgrest.conf
 ---> 0928a4dc3a95
Step 5/7 : ENV PGRST_DB_URI=     PGRST_DB_SCHEMA=public     PGRST_DB_ANON_ROLE=     PGRST_DB_POOL=100     PGRST_SERVER_HOST=*4     PGRST_SERVER_PORT=3000     PGRST_SERVER_PROXY_URI=     PGRST_JWT_SECRET=     PGRST_SECRET_IS_BASE64=false     PGRST_JWT_AUD=     PGRST_MAX_ROWS=     PGRST_PRE_REQUEST=
 ---> Running in 4458eeeea231
Removing intermediate container 4458eeeea231
 ---> 8ea0f4dcd2ac
Step 6/7 : CMD exec postgrest /etc/postgrest.conf
 ---> Running in d8b9fbad480e
Removing intermediate container d8b9fbad480e
 ---> ef92c785c1ac
Step 7/7 : EXPOSE 3000
 ---> Running in 2c9506ab50fb
Removing intermediate container 2c9506ab50fb
 ---> d1edae7d5ffd
Successfully built d1edae7d5ffd
Successfully tagged postgrest:arm

The docker run command:

pi@raspberrypi:~/PostGrest $ docker run -i -t  postgrest:arm /bin/bash
root@34cb5732774d:/# whoami
root
root@34cb5732774d:/# uname -a
Linux 34cb5732774d 4.14.34-v7+ #1110 SMP Mon Apr 16 15:18:51 BST 2018 armv7l GNU/Linux
root@34cb5732774d:/# postgrest
bash: /usr/local/bin/postgrest: No such file or directory

@nicolastarzia Before creating the docker image would be better to see if the binary is working in your rpi, see if you can run ./postgrest(it should show a help output) only requirement should be to apt-get install libpq-dev.

Just a quick update:

I opened the issue a couple of days ago and since then I'm being idle because my memory card is corrupted so I cannot test it myself.

I already ordered a new one more than a week ago, but then a truck drivers strike has been delaying the delivery.

Many thanks @steve-chavez and @nicolastarzia for the inputs, I'm gonna get back to you as soon as my Raspberry Pi gets a new memory card : )

Compiled version on Raspberry Jessie

postgrest.tar.xz.zip

Marcello

Thanks @marcellodgl, want to add that this binary(armv7) corresponds to the latest version(v5.0.0) on https://github.com/PostgREST/postgrest/commit/fa1e92fdf2d74d083eb4242de5051b0274799a17, and also that we confirmed it's working ok on Marcello's rpi, unlike my previously posted binary which presented some errors, so prefer this latest binary.

Compiled version on Raspberry Jessie

postgrest.tar.xz.zip

Marcello

I loaded your binary in my custom postgrest Dockerfile (same as original, but without installing postgrest) and I can confirm it is working on a RPI3.

@steve-chavez Is there a new version of the RaspberryPi/Arm32 build? Could you please share your working recipe?
I tried building the latest postgREST branch using arm32v7/debian docker image but it failed with the following error:

--  While building package haskell-src-exts-1.18.2 using:
      /root/.stack/setup-exe-cache/arm-linux/Cabal-simple_mPHDZzAJ_1.24.2.0_ghc-8.0.2 --builddir=.stack-work/dist/arm-linux/Cabal-1.24.2.0 build --ghc-options " -ddump-hi -ddump-to-file"
    Process exited with code: ExitFailure 1
    Logs have been written to: /app/postgrest/.stack-work/logs/haskell-src-exts-1.18.2.log

    Configuring haskell-src-exts-1.18.2...
    Building haskell-src-exts-1.18.2...
    Preprocessing library haskell-src-exts-1.18.2...
    [ 1 of 17] Compiling Language.Haskell.Exts.Syntax ( src/Language/Haskell/Exts/Syntax.hs, .stack-work/dist/arm-linux/Cabal-1.24.2.0/build/Language/Haskell/Exts/Syntax.o )
    `opt' failed in phase `LLVM Optimiser'. (Exit code: -9)

It takes ~3 hours to get to the error I posted above. Here's the complete log:
docker.log

I'm creating a base arm32v7/debian image with required dependencies using this

base Dockerfile

The final Dockerfile used to build postgREST is:
Dockerfile

@samkhawase No new version from my part.

It takes ~3 hours to get to the error I posted above

Yeah, building through docker takes that long. I really don't want to go through that again.

That being said, I'm interested in offering official ARM binaries, but it'd be better to produce them natively.
I've been looking at https://cloud.drone.io, we could integrate that CI and produce the binaries on each release.

Edit: Travis also supports arm64: https://docs.travis-ci.com/user/multi-cpu-architectures/#testing-on-multiple-cpu-architectures

@steve-chavez Well that's a bummer 鈽癸笍 I'm not well versed with the Haskell/Stack build system, so I'm not sure how can I figure it out. It would be interesting to know if you can levarage https://cloud.drone.io to create Arm32/Arm64 binaries.

Ok. So I bought an ARMv8 instance from scaleway, setup a build environment based on nix, build the postgrest 5.2.2 for aarch64 and push to my docker hub repository. You can pull it with following command:
docker pull hughjfchen/hughjfchen:postgrest-aarch64-5.2.0

@hughjfchen Cool!

I think we should aim to integrate a Nix CI. Ideally we'd also offer static binaries for aarch32/64.

Is there a solution now?

@hughjfchen Could you please share the build details?
I have a scaleway Arm64 server and I could setup a CI build on it.

@hughjfchen Could you please share the build details?
I have a scaleway Arm64 server and I could setup a CI build on it.

I've been building the postgrest docker images for aarch64 recently. You can use it by pulling the images from my docker.io repos:
docker pull hughjfchen/hughjfchen:postgrest-aarch64-5.2.0
or:
docker pull hughjfchen/hughjfchen:postgrest-aarch64-6.0.2

If you want to play around with my build process, I have a github repos which builds the above images with my home-made shell-script-based CI/CD framework. You can build on your scaleway arm64 instance with following steps:

  1. make sure you have an account which can use sudo without password
  2. clone my github repos with the command: git clone https://github.com/hughjfchen/postgrest-docker
    3.build the images with one of the following commands:
    postgrest-docker/postgrest-6.0/DevOps/scaleway/test/cb.sh, or
    postgrest-docker/postgrest-5.2/DevOps/scaleway/test/cb.sh
    4.once finished, you can find the nix derivation result under the postgrest-docker/postgrest-6.0 or postgrest-docker/postgrest-5.2 directory respectively.

@hughjfchen Could you please share the build details?
I have a scaleway Arm64 server and I could setup a CI build on it.

I've been building the postgrest docker images for aarch64 recently. You can use it by pulling the images from my docker.io repos:
docker pull hughjfchen/hughjfchen:postgrest-aarch64-5.2.0
or:
docker pull hughjfchen/hughjfchen:postgrest-aarch64-6.0.2

If you want to play around with my build process, I have a github repos which builds the above images with my home-made shell-script-based CI/CD framework. You can build on your scaleway arm64 instance with following steps:

1. make sure you have an account which can use `sudo` without password

2. clone my github repos with the command: `git clone https://github.com/hughjfchen/postgrest-docker`
   3.build the images with one of the following commands:
   `postgrest-docker/postgrest-6.0/DevOps/scaleway/test/cb.sh`, or
   `postgrest-docker/postgrest-5.2/DevOps/scaleway/test/cb.sh`
   4.once finished, you can find the nix derivation result under the `postgrest-docker/postgrest-6.0` or `postgrest-docker/postgrest-5.2` directory respectively.

@steve-chavez Can we setup a CI, and add the ARM64 builds to the official releases?

@samkhawase Sure, if you build an arm64 binary in your CI and share it here I could add it to https://github.com/PostgREST/postgrest/releases.

Is that what you had in mind?

@steve-chavez I can provide the binary for arm64, however, since I build the binary with nix, it will depend on some nix derivations which need to be installed on the target environment. Is this acceptable? If yes, I can tar the binary and its dependencies up and you can add it to the release.

@hughjfchen Could you make it a statically linked binary? You could try modifying this nix expression for postgrest 6.0.1 which was shared in https://github.com/PostgREST/postgrest/issues/1295. That way it would run in any linux distro(I think most users aren't running nix).

If there's an executable, that's great

@hughjfchen Could you make it a statically linked binary? You could try modifying this nix expression for postgrest 6.0.1 which was shared in #1295. That way it would run in any linux distro(I think most users aren't running nix).

@steve-chavez , I've been trying to build postgrest statically with the nix expression you linked, however, I'd stuck at the following error:
building '/nix/store/5i4lphsaikc4mjzaklcnwhv033l6cyjb-bootstrap-tools.tar.xz.drv'... warning: unable to download 'https://wdtz.org/files/wjzsj9cmdkc70f78yh072483x8656nci-stdenv-bootstrap-tools-aarch64-unknown-linux-musl/on-server/bootstrap-tools.tar.xz': SSL connect error (35); retrying in 257 ms warning: unable to download 'https://wdtz.org/files/wjzsj9cmdkc70f78yh072483x8656nci-stdenv-bootstrap-tools-aarch64-unknown-linux-musl/on-server/bootstrap-tools.tar.xz': SSL connect error (35); retrying in 649 ms warning: unable to download 'https://wdtz.org/files/wjzsj9cmdkc70f78yh072483x8656nci-stdenv-bootstrap-tools-aarch64-unknown-linux-musl/on-server/bootstrap-tools.tar.xz': SSL connect error (35); retrying in 1022 ms warning: unable to download 'https://wdtz.org/files/wjzsj9cmdkc70f78yh072483x8656nci-stdenv-bootstrap-tools-aarch64-unknown-linux-musl/on-server/bootstrap-tools.tar.xz': SSL connect error (35); retrying in 2096 ms error: unable to download 'https://wdtz.org/files/wjzsj9cmdkc70f78yh072483x8656nci-stdenv-bootstrap-tools-aarch64-unknown-linux-musl/on-server/bootstrap-tools.tar.xz': SSL connect error (35) builder for '/nix/store/5i4lphsaikc4mjzaklcnwhv033l6cyjb-bootstrap-tools.tar.xz.drv' failed with exit code 1
Looks like my scaleway instance can't access the wdtz.org site due to some ssl problem. Do you guys meet such a problem before?

@hughjfchen Looks like that url is defined here https://github.com/NixOS/nixpkgs/blob/master/pkgs/stdenv/linux/bootstrap-files/x86_64-musl.nix#L8.

Maybe it was a temporary issue? I'm able to download https://wdtz.org/files/gywxhjgl70sxippa0pxs0vj5qcgz1wi8-stdenv-bootstrap-tools/on-server/bootstrap-tools.tar.xz now.

I didn't run into that problem when builiding the static 6.0.1. It can take a long time though.

@steve-chavez , I fixed the 'unable to download' problem by upgrading nix to 2.3.3 which uses a newer version of libcurl. However, I'm now stuck at building the gnu coreutils which says a test case, test-init.sh, failed with an error: Segmentation fault. I don't know how to fix that. The only option which I can think about is try some binary cache from another nix store, maybe static-haskell-nix? Any suggestions?

@hughjfchen On https://github.com/PostgREST/postgrest/issues/1295#issuecomment-517112721 it was mentioned that you could use cachix use static-haskell-nix. Maybe with that you can avoid building gnu coreutils locally.

It took me 3 days to install cachix which builds everything from scratch. But unfortunately, I cannot use the static-haskell-nix binary cache because the nix version I'm using is not the same as the static-haskell-nix is using.

It took me 3 days to install cachix which builds everything from scratch.

@hughjfchen Argh, I'm really sorry for offering you terrible advice there.

I see you also reported the coreutils issue on https://github.com/NixOS/nix/issues/1973#issuecomment-601551473. Unfortunately, I can't be of further help on this. Solving the coreutils error might require patching upstream.

@steve-chavez , No need to be sorry, it just looks like that ARM is still a "second tier" target platform for haskell and nix. As you said, I'd already reported the problem upstream. Let's see what'll happen next.
Back to this issue's original title, for a docker image, I think a binary statically linked to its haskell dependencies and dynamically linked to some system libraries, like glibc, libpq, is OK. This is the way I go with to build the docker images. You can pull the images from my docker hub repos and play around.

dtzWill has been updated the upstream and I'm now rebuilding the static binary. Let's see if it can be built successfully.

Thanks @hughjfchen and @steve-chavez for your efforts to provide an ARM image. Can't wait to try it out!

Thanks @hughjfchen and @steve-chavez

Unfortunately, I haven't be able to get a fully statically linked binary for ARM platform, yet. I still stuck at building the coreutils and waiting for the upstream.

@steve-chavez

postgrest-armv7.tar.gz

This does not appear to be statically linked (output from ldd below).

I modified the Dockerfile in the the repository to use this binary instead of downloading one, and built an image from that. It appears to work without any issues.

image

I'm trying to run our nix static build setup on an AWS t4g(ARM) instance, but I'm getting an issue when trying to use nix-shell:

> nix-shell
Patchelfing /nix/store/d56lx3bxdvpxii0c85wv8yqya24sd3m2-ghc-8.6.5-binary/lib/ghc-8.6.5/bytestring-0.10.8.2/libHSbytestring-0.10.8.2-ghc8.6.5.so
Patchelfing /nix/store/d56lx3bxdvpxii0c85wv8yqya24sd3m2-ghc-8.6.5-binary/lib/ghc-8.6.5/transformers-0.5.6.2/libHStransformers-0.5.6.2-ghc8.6.5.so
running install tests
/nix/store/k832pghqg9z887j8py47ddhwzrn4yj1f-stdenv-linux/setup: line 1310:  3361 Segmentation fault      (core dumped) $out/bin/ghc --make main.hs

Seems related to:

Would love to see this when it is ready, am happy to help test

I no longer run the ARM64 server since Scaleway shut that down, but can someone with an M1 Macbook/Mac Mini help us with the ARM/ARM64 builds?

Github will build them for free - with github actions

Cool, time to play with GH Actions then :-)

I successfully built the ARM binary on an AWS t4g instance(ubuntu) , but now I'm having trouble building it on Travis.

@samkhawase In case it helps, here are the steps I'm following: https://github.com/steve-chavez/postgrest/blob/travis-arm/.travis.yml#L82-L99.

Also AFAICT, stack doesn't work on ARM, right?

Seems travis has an issue with ARM64. I keep getting a No output has been received in the last 10m0s. See: https://github.com/cilium/cilium/issues/10945. Some runs where I got this error:

So it's definitely worth to look at another CI for automating the build.

Manually building the ARM64 works fine though. I'll upload the ubuntu build on our nightly release.

Done. I uploaded postgrest-nightly-2020-11-10-22-47-3830887-ubuntu-aarch64.tar.xz on nightly.

The dependencies for the binary to run:

sudo apt -y install libpq5
sudo apt -y install libatomic1

I think it's fine to upload aarch64 binaries for different distros until the static binary works.

Support, hope have different distros of mainstream version

Note that the above binary only works for ubuntu focal(20.04) and not for ubuntu bionic(18.04). It will give an error when tried on bionic:

$ ./postgrest
./postgrest: error while loading shared libraries: libffi.so.7: cannot open shared object file: No such file or directory

So now I've uploaded a binary for bionic - had several issues for building this one since its packages for ghc/cabal are outdated.
It's called postgrest-nightly-2020-12-09-14-20-ebd474a-ubuntu-bionic-aarch64.tar.xz under the nightly page.

Perhaps I'll switch to just building this one because I've noted that it also runs on focal.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

LorenzHenk picture LorenzHenk  路  23Comments

tomberek picture tomberek  路  19Comments

posix4e picture posix4e  路  34Comments

opensrcery picture opensrcery  路  39Comments

ric2b picture ric2b  路  21Comments