-
-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Comments
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 |
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 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 Line 17 in f6c1ff8
It should be like The binary I built has this
|
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 |
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 Marcello |
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. |
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?
|
It takes ~3 hours to get to the error I posted above. Here's the complete log: I'm creating a base The final Dockerfile used to build postgREST is: |
@samkhawase No new version from my part.
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. 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 |
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: |
@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've been building the postgrest docker images for aarch64 recently. You can use it by pulling the images from my docker.io repos: 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:
|
@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 #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 |
@steve-chavez , I've been trying to build postgrest statically with the nix expression you linked, however, I'd stuck at the following error: |
@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 #1295 (comment) it was mentioned that you could use |
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. |
This does not appear to be statically linked (output from 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. |
I'm trying to run our nix static build setup on an AWS > 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
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 The dependencies for the binary to run:
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:
So now I've uploaded a binary for bionic - had several issues for building this one since its packages for ghc/cabal are outdated. Perhaps I'll switch to just building this one because I've noted that it also runs on focal. |
On my system (latest Dockerhub image of ubuntu:20.04) I got this while running the nightly aarch64 from
|
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. |
@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( (Sample Dockerfile here) |
@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: The best workaround for now is the answer here: |
@steve-chavez there will be made an armv7 version? |
@hughjfchen Thanks ! It works for me |
@albertobissacco There is a new PostgREST armv7 Docker image for v9.0.0 and latest and a new binary in the release page. |
Environment
postgres:10.4
v0.5.0.0
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:
Also I see only
amd64
in the image inspector:Is this possible and in the radar for short term releases? Is there someway I could help in this particular issue?
The text was updated successfully, but these errors were encountered: