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

17-3.5/alpine/Dockerfile cannot build with arm64 ( QEMU/BUILDX ) #393

Closed
MrLiuzy opened this issue Sep 30, 2024 · 7 comments
Closed

17-3.5/alpine/Dockerfile cannot build with arm64 ( QEMU/BUILDX ) #393

MrLiuzy opened this issue Sep 30, 2024 · 7 comments
Labels
QEMU QEMU/BUILDX related

Comments

@MrLiuzy
Copy link

MrLiuzy commented Sep 30, 2024

I want to build a image with arm64, but when I run docker build, two problems arise

  1. The dockerfile has an error in line 80 “&& cd regress \” , the correct path is "&& cd /usr/src/postgis/regress "
  2. regress/core/binary ..Died at ../regress/run_test.pl line 979. failed (psql exited with an error: /tmp/pgis_reg/test_3_out) make: *** [runtest.mk:24: check-regress] Error 2
    anyone can help?
@ImreSamu
Copy link
Member

Interesting problem.

Could you provide more details?

  • For example, are you using native CPU or emulation? What exact CPU are you using? ARM v8, v9? And any other relevant information would be helpful.

Also, what command are you using to build the Docker image?

  • Does it include --pull ( "Always attempt to pull all referenced images" ) , for instance?

Could you also test the Dockerfile found in the docker-postgis ~test environment?
( https://github.com/imresamu/docker-postgis/blob/master/17-3.5/alpine3.20/Dockerfile )
It successfully builds on CircleCI Arm64, and arm64 images are available on Docker Hub, so it should definitely work.
In fact, all Dockerfiles in the imresamu/docker-postgis repository run successfully on Arm64.

@crystaldonut
Copy link

crystaldonut commented Oct 1, 2024

Hi there on my end i'm using arm64/v8 afaik

Running on my raspberry pi 5

cat /etc/os-release
PRETTY_NAME="Debian GNU/Linux 12 (bookworm)"
NAME="Debian GNU/Linux"
VERSION_ID="12"
VERSION="12 (bookworm)"
VERSION_CODENAME=bookworm
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"

uname -a
Linux pibox 6.6.31+rpt-rpi-2712 #1 SMP PREEMPT Debian 1:6.6.31-1+rpt1 (2024-05-29) aarch64 GNU/Linux

cmd :
docker run --name postgis -e POSTGRES_PASSWORD=mysecretpassword -d postgis/postgis

...
Status: Downloaded newer image for postgis/postgis:latest
WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested

Hope it helps

@MrLiuzy
Copy link
Author

MrLiuzy commented Oct 8, 2024

@ImreSamu Hi, ImreSamu. The docker build detail was:
the Dockerfile from https://github.com/postgis/docker-postgis/blob/master/17-3.5/alpine/Dockerfile
the postgresql arm64 image 'postgres:17-alpine3.20'
OS windows11(x86)
build cmd was 'docker buildx build --platform linux/arm64 -t postgres:17-alpine3.20-arm64 -f Dockerfile . --load'

First time I run the build cmd , it tips an error that 'cd regress' directory not exists. so I modify the instruct 'cd regress' to 'cd /usr/src/postgis/regress' then this error was gone! But I got another error, 'regress/core/binary ..Died at ../regress/run_test.pl line 979. failed (psql exited with an error: /tmp/pgis_reg/test_3_out) make: *** [runtest.mk:24: check-regress] Error 2'

@ImreSamu
Copy link
Member

ImreSamu commented Oct 8, 2024

@MrLiuzy :

OS windows11(x86) ... docker buildx build --platform linux/arm64

We are unable to fully support building on Windows or using QEMU, as there are many potential compatibility issues. If building is important, I recommend using Windows WSL2 without CPU emulation, meaning in native x86 mode.

The issues I’m aware of:

  • Different operating system end-of-line encoding. ( local build image for testing source changes docker-library/postgres#1197 )
  • QEMU/BUILDX emulation problems. Previously, regression tests only ran successfully in "--jit=off" mode, which means it's best to use this mode in production. However, it’s possible that a more recent version of QEMU has resolved this issue.

About two years ago, I found the following patch ( need to adapt ) :
#312
the key part: && su postgres -c 'pg_ctl -o "--jit=off" -D /tempdb start' \

    # QEMU7.0/BUILDX - JIT workaround
    && if [[ "$(uname -m)" == "aarch64" && "14" != "10" ]] || \
          [[ "$(uname -m)" == "ppc64le" && "14" != "10" ]]; then \
            set -eux \
            # for the buildx/qemu workflow
            #   with (aarch64 ppc64le) and PG>10 .. we are testing with JIT=OFF to avoid QEMU7.0/BUILDX error
            && echo "WARNING: JIT=OFF testing (aarch64 ppc64le)!" \
            && echo "## WARNING: tested with JIT=OFF (aarch64 ppc64le)!" >> /_pgis_full_version.txt \
            && su postgres -c 'pg_ctl -o "--jit=off" -D /tempdb start' \
            && su postgres -c 'psql -c "SHOW JIT;"' \
            ; \
        else \
            set -eux \
            # default test .. no problem expected.
            && su postgres -c 'pg_ctl -D /tempdb start' \
            ; \
        fi \
    \

My personal opinion:
Due to the emulation issues, we ( ~ docker-postgis repo) don't use BUILDX/QEMU for ARM64 builds. I'm not sure about the current status of the problem, but if the QEMU-ARM64-JIT issue hasn’t been resolved, I wouldn’t recommend this method for running PostgreSQL/PostGIS. If any third-party code enables JIT, unexpected problems could arise. Without thorough regression testing, we might have overlooked this issue ourselves.

Of course, if there's no other alternative, I would definitely use JIT=OFF. ( in test and in production )
The key point is that I spent several weeks dealing with the QEMU-ARM64-JIT issue, so I would advise caution in this matter.
Currently, the latest version is QEMU 9.1.0, but I tested with QEMU 7.

In any case, if the test only runs with JIT=OFF for you, then the issue still persists.

@ImreSamu ImreSamu changed the title 17-3.5/alpine/Dockerfile cannot build with arm64 17-3.5/alpine/Dockerfile cannot build with arm64 ( QEMU/BUILDX ) Oct 8, 2024
@ImreSamu ImreSamu added the QEMU QEMU/BUILDX related label Oct 8, 2024
@MrLiuzy
Copy link
Author

MrLiuzy commented Oct 9, 2024

@ImreSamu Thanks for your reply! I know the reason for the issue.
I tried to pull arm64 image with name 'postgis/postgis:17-3.5-alpine', but it failed! Can you tell me the correct arm64 docker image name?

@ImreSamu
Copy link
Member

ImreSamu commented Oct 9, 2024

@MrLiuzy :

I tried to pull arm64 image with name 'postgis/postgis:17-3.5-alpine', but it failed!

Unfortunately, what is stated in the README.md is currently true:

Versions (2024-09-27)
Supported architecture: amd64 (also known as X86-64)"

So there is no Arm64/AArch64 image. ( yet )


There is only a test image for Arm64 in my test system , as I mentioned in my first comment. Were you able to try that?

See : https://registry.hub.docker.com/r/imresamu/postgis/tags?page=1&name=17-3.5.0-alpine3.20

  • --> "linux/arm64"
    • docker pull imresamu/postgis:17-3.5.0-alpine3.20

image

@MrLiuzy
Copy link
Author

MrLiuzy commented Oct 10, 2024

@ImreSamu Thank you so much!

@MrLiuzy MrLiuzy closed this as completed Oct 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
QEMU QEMU/BUILDX related
Projects
None yet
Development

No branches or pull requests

3 participants