postgis / docker-postgis

Docker image for PostGIS
https://hub.docker.com/r/postgis/postgis/
MIT License
1.39k stars 466 forks source link

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

Closed MrLiuzy closed 3 weeks ago

MrLiuzy commented 1 month ago

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 commented 1 month ago

Interesting problem.

Could you provide more details?

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

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 commented 1 month ago

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 commented 4 weeks ago

@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 commented 4 weeks ago

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

About two years ago, I found the following patch ( need to adapt ) : https://github.com/postgis/docker-postgis/pull/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.

MrLiuzy commented 3 weeks ago

@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 commented 3 weeks ago

@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

image

MrLiuzy commented 3 weeks ago

@ImreSamu Thank you so much!