gis-ops / docker-valhalla

This is our flexible Docker repository for the Valhalla routing engine
MIT License
248 stars 70 forks source link

Unable to build docker image on M2 macOS #120

Closed Asher-JH closed 1 year ago

Asher-JH commented 1 year ago

I was having trouble running the pulled Docker image, would run into a platform issue when trying to run it.

So I have cloned the repo & tried building the Docker image with this command as following the docs: docker build -t ghcr.io/gis-ops/docker-valhalla/valhalla:latest .

Results in the below build error:

[+] Building 1.1s (15/15) FINISHED docker:orbstack => [internal] load build definition from Dockerfile 0.0s => => transferring dockerfile: 3.35kB 0.0s => [internal] load .dockerignore 0.0s => => transferring context: 135B 0.0s => [internal] load metadata for docker.io/library/ubuntu:22.04 1.0s => [internal] load metadata for ghcr.io/valhalla/valhalla:latest 0.9s => [runner_base 1/8] FROM docker.io/library/ubuntu:22.04@sha256:0bced47fffa3361afa981854fcabcd4577cd43cebbb808cea2b1f33a3dd7f508 0.0s => [internal] load build context 0.0s => => transferring context: 298B 0.0s => [builder 1/2] FROM ghcr.io/valhalla/valhalla:latest@sha256:ebfb242d27232a211a8d55271a12cc46ccfb4aaa273d3cbfe1a550573fdea43c 0.0s => CACHED [runner_base 2/8] RUN apt-get update > /dev/null && export DEBIAN_FRONTEND=noninteractive && apt-get install -y lib 0.0s => CACHED [builder 2/2] RUN cd /usr/local/bin && preserve="valhalla_service valhalla_build_tiles valhalla_build_config valhalla_bui 0.0s => CACHED [runner_base 3/8] COPY --from=builder /usr/local /usr/local 0.0s => CACHED [runner_base 4/8] COPY --from=builder /usr/lib/python3/dist-packages/valhalla/ /usr/lib/python3/dist-packages/valhalla/ 0.0s => CACHED [runner_base 5/8] RUN groupadd -g 59999 valhalla && useradd -lmu 59999 -g valhalla valhalla && mkdir /custom_files && 0.0s => CACHED [runner_base 6/8] COPY scripts/. /valhalla/scripts 0.0s => CACHED [runner_base 7/8] WORKDIR /custom_files 0.0s => ERROR [runner_base 8/8] RUN python -c "import valhalla,sys; print (sys.version, valhalla)" && valhalla_build_config | jq type 0.1s [runner_base 8/8] RUN python -c "import valhalla,sys; print (sys.version, valhalla)" && valhalla_build_config | jq type && cat /usr/local/src/valhalla_version && valhalla_build_tiles -v && ls -la /usr/local/bin/valhalla: 0.064 Traceback (most recent call last): 0.064 File "/usr/lib/python3/dist-packages/valhalla/init.py", line 2, in 0.064 from .python_valhalla import 0.064 ModuleNotFoundError: No module named 'valhalla.python_valhalla' 0.064 0.064 During handling of the above exception, another exception occurred: 0.064 0.064 Traceback (most recent call last): 0.064 File "", line 1, in 0.064 File "/usr/lib/python3/dist-packages/valhalla/init.py", line 4, in 0.064 from python_valhalla import 0.064 ModuleNotFoundError: No module named 'python_valhalla' Dockerfile:55

54 | # Smoke tests 55 | >>> RUN python -c "import valhalla,sys; print (sys.version, valhalla)" \ 56 | >>> && valhalla_build_config | jq type \ 57 | >>> && cat /usr/local/src/valhalla_version \ 58 | >>> && valhalla_build_tiles -v \ 59 | >>> && ls -la /usr/local/bin/valhalla* 60 |

ERROR: failed to solve: process "/bin/sh -c python -c \"import valhalla,sys; print (sys.version, valhalla)\" && > valhalla_build_config | jq type && cat /usr/local/src/valhalla_version && valhalla_build_tiles -v && ls -la > /usr/local/bin/valhalla*" did not complete successfully: exit code: 1

Running on M2 Mac Latest repo cloned

Any help would be greatly appreciated

ImreSamu commented 1 year ago

Can you please verify using: Architecture: x86_64? ( with --platform linux/amd64 ) Does the command

docker build --platform linux/amd64 -t ghcr.io/gis-ops/docker-valhalla/valhalla:latest . 

work for you?

related1:

related2:

Asher-JH commented 1 year ago

Thanks, using the --platform flags makes the build run successfully but now I'm facing the same issue in the related issue you mentioned in you comment.

janfigala commented 11 months ago

I'm getting the same error on M1 Mac as well as Google Cloud Build, even with --platform linux/amd64 specified.

I've forked the project and downgraded the builder image to ARG VALHALLA_BUILDER_IMAGE=ghcr.io/valhalla/valhalla:3.4.0 in the Dockerfile which built successfully.

So it looks like there's an issue with the current valhalla/valhalla:latest image.