Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docker image compatible with ARM: is that possible? #1117

Closed
cuducos opened this issue May 20, 2018 · 53 comments
Closed

Docker image compatible with ARM: is that possible? #1117

cuducos opened this issue May 20, 2018 · 53 comments
Labels
ci Related to CI setup

Comments

@cuducos
Copy link

cuducos commented May 20, 2018

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?

@steve-chavez
Copy link
Member

steve-chavez commented May 21, 2018

Edit: Prefer the binary in #1117 (comment), 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

@nicolastarzia
Copy link

nicolastarzia commented May 25, 2018

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 && \

@steve-chavez
Copy link
Member

steve-chavez commented May 25, 2018

@nicolastarzia Maybe you're missing a change to this line

tar -xJvf postgrest-${POSTGREST_VERSION}-ubuntu.tar.xz && \
.

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

@nicolastarzia
Copy link

nicolastarzia commented May 25, 2018

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

@steve-chavez
Copy link
Member

@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.

@cuducos
Copy link
Author

cuducos commented May 29, 2018

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

@marcellodgl
Copy link

Compiled version on Raspberry Jessie

postgrest.tar.xz.zip

Marcello

@steve-chavez
Copy link
Member

Thanks @marcellodgl, want to add that this binary(armv7) corresponds to the latest version(v5.0.0) on fa1e92f, 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.

@pedroetb
Copy link

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.

@samkhawase
Copy link
Contributor

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

@samkhawase
Copy link
Contributor

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

@steve-chavez
Copy link
Member

steve-chavez commented Apr 29, 2019

@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

@samkhawase
Copy link
Contributor

@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.

@steve-chavez steve-chavez added the ci Related to CI setup label Sep 10, 2019
@hughjfchen
Copy link

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

@steve-chavez
Copy link
Member

@hughjfchen Cool!

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

@fenggy
Copy link

fenggy commented Mar 9, 2020

Is there a solution now?

@samkhawase
Copy link
Contributor

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

@hughjfchen
Copy link

@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.

@samkhawase
Copy link
Contributor

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

@steve-chavez
Copy link
Member

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

@hughjfchen
Copy link

@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.

@steve-chavez
Copy link
Member

@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).

@fenggy
Copy link

fenggy commented Mar 15, 2020

If there's an executable, that's great

@hughjfchen
Copy link

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

@steve-chavez
Copy link
Member

steve-chavez commented Mar 19, 2020

@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.

@hughjfchen
Copy link

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

@steve-chavez
Copy link
Member

@hughjfchen On #1295 (comment) it was mentioned that you could use cachix use static-haskell-nix. Maybe with that you can avoid building gnu coreutils locally.

@samkhawase
Copy link
Contributor

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

@fenggy
Copy link

fenggy commented Apr 4, 2020

Thanks @hughjfchen and @steve-chavez

@hughjfchen
Copy link

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.

@andytango
Copy link
Contributor

@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

@steve-chavez
Copy link
Member

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:

@pixie79
Copy link

pixie79 commented Nov 27, 2020

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

@samkhawase
Copy link
Contributor

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?

@pixie79
Copy link

pixie79 commented Nov 27, 2020

Github will build them for free - with github actions

@samkhawase
Copy link
Contributor

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

@steve-chavez
Copy link
Member

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?

@steve-chavez
Copy link
Member

Seems travis has an issue with ARM64. I keep getting a No output has been received in the last 10m0s. See: cilium/cilium#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.

@steve-chavez
Copy link
Member

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.

@fenggy
Copy link

fenggy commented Dec 2, 2020

Support, hope have different distros of mainstream version

@steve-chavez
Copy link
Member

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.

@crrobinson14
Copy link

On my system (latest Dockerhub image of ubuntu:20.04) I got this while running the nightly aarch64 from postgrest-nightly-2021-01-25-18-38-c93e8f9-ubuntu-aarch64.tar.xz:

postgrest: error while loading shared libraries: libnuma.so.1: cannot open shared object file: No such file or directory

apt install libnuma-dev resolved this. Just reporting here for the record.

@saxomagic
Copy link

Hi - closed #1979 because it is a duplicate, but not because it has been resolved - just making sure there is no misunderstanding. Would very much appreciate an arm64 M1-compatible docker image built with Nix. Also, documentation is not clear on how to proceed with the Nix build using the Nix docker image for running the nix-shell for build and dev, so perhaps a bit more there on how to actually get the Nix-built docker image of PostgREST out into DockerHub? Apologies if that part is self study / common knowledge, but having build docker images with docker build and pushed to DockerHub before, this method with Nix is quite a bit different.
Btw, the documentation is really awesome in general, so my compliments to all the effort that has gone into that - learned a lot just by reading it - thanks much.

@steve-chavez
Copy link
Member

steve-chavez commented Oct 22, 2021

@saxomagic I think we can do the docker release for ARM manually for now(not in CI or using Nix).

Basically using docker buildx build --platform linux/arm64 and a custom Dockerfile using our ARM binary for Ubuntu( postgrest-v8.0.0-ubuntu-aarch64.tar.xz).

(Sample Dockerfile here)

@steve-chavez
Copy link
Member

There's now a PostgREST ARM Docker image for v9.0.0 and latest.

@saxomagic
Copy link

@steve-chavez thank you very, very much! It seems to be working fine. Another challenge though is PostgreSQL itself, for which there are ARM 64-bit docker images, but they do have issues still running on M1 chips:
docker/for-mac#5830
docker/for-mac#5407
docker/for-mac#5590

The best workaround for now is the answer here:
https://stackoverflow.com/questions/65687712/postgres-errors-on-arm-based-m1-mac-w-big-sur

@albertobissacco
Copy link

@steve-chavez there will be made an armv7 version?

@maxgfr
Copy link

maxgfr commented Dec 8, 2021

@hughjfchen Thanks ! It works for me

@laurenceisla
Copy link
Member

@albertobissacco There is a new PostgREST armv7 Docker image for v9.0.0 and latest and a new binary in the release page.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ci Related to CI setup
Development

No branches or pull requests