gis-ops / docker-valhalla

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

docker build fails on M1 #15

Closed homtec closed 3 years ago

homtec commented 3 years ago

Hey,

running docker build -t gisops/valhalla --build-arg VALHALLA_RELEASE=3.1.0 . on a Mac M1 fails with

 => ERROR [runner 6/7] COPY --from=builder /usr/local/lib/python3.8/dist-packages/python_valhalla.cpython-38-x86_64-linux-gnu.so /usr/lib/python3.8/dist-packages                                                           0.0s
------
 > [runner 6/7] COPY --from=builder /usr/local/lib/python3.8/dist-packages/python_valhalla.cpython-38-x86_64-linux-gnu.so /usr/lib/python3.8/dist-packages:
------
failed to compute cache key: "/usr/local/lib/python3.8/dist-packages/python_valhalla.cpython-38-x86_64-linux-gnu.so" not found: not found

I guess referencing the x86_64 architecture is an issue. Any idea how to fix this step in the Dockerfile?

nilsnolde commented 3 years ago

Huh.. How's that even possible?! That should be entirely independent of your machine, it runs on 20.04. As to patch it: you see which step is failing, so just comment that line in the Dockerfile.

Even more odd since the dockerhub build has no issues: https://hub.docker.com/layers/134762402/gisops/valhalla/3.1.0/images/sha256-7bded18f5a0c91d356963c2581715068c858fc771e8f82d364bd41641f96668d?context=explore

I'd recommend pulling that one if you can.

Still, this shouldn't happen.. Though there is a glitch with the bindings I just realized, but that's irrelevant for your problem.

nilsnolde commented 3 years ago

But I did hear strange things about M1 and docker.. Did you experience any other oddities with other images?

nilsnolde commented 3 years ago

Ah of course you're right.. sorry.. x86 on arm. ha that's annoying! then patching is indeed your best bet. maybe I should add an optional WITH_PYTHON build arg..

homtec commented 3 years ago

My firs approach was to run your pre-build image from dockerhub, its emulated as there is no arm64 image. But it crashes and I think that's due to a docker issue (its stilla tech preview for the M1). So I tried to build my own image.

Commenting out the python line works. However I don't know what functionality I'm missing without the python binding.

nilsnolde commented 3 years ago

Ok cool, good to hear! I'll pin the issue for other people.

The bindings are really cool but hardly usable from the host machine anyways without quite some hacks, so don't worry. We're working towards Valhalla as a stand-alone Python package, though that'll be commercial.

homtec commented 3 years ago

The docker build runs successfully. Running the script quits with a segmentation fault:

=========================
= Build the tile files. =
=========================
Running build tiles with: /custom_files/valhalla.json  /custom_files/germany-latest.osm.pbf
2021/02/07 14:23:37.906199 [INFO] Start stage = initialize End stage = cleanup
2021/02/07 14:23:37.907508 [INFO] Parsing files for ways: /custom_files/germany-latest.osm.pbf
2021/02/07 14:23:37.908632 [INFO] Parsing ways...
/valhalla/scripts/configure_valhalla.sh: line 317:    11 Segmentation fault      valhalla_build_tiles -c ${config_file} ${files}
Found config file. Starting valhalla service!
2021/02/07 14:24:18.854817 [ERROR] (stat): /custom_files/valhalla_tiles.tar No such file or directory
2021/02/07 14:24:18.854924 [WARN] Tile extract could not be loaded
2021/02/07 14:24:18.857661 [WARN] (stat): /data/valhalla/traffic.tar No such file or directory
2021/02/07 14:24:18.857674 [WARN] Traffic tile extract could not be loaded
2021/02/07 14:24:18.945634 [WARN] /data/valhalla/elevation/ currently has no elevation tiles

But that's probably out of your control and due to docker/Valhalla/M1 setup. Giving up at this point ;-)

nilsnolde commented 3 years ago

Oops, that's sad.. Would be interesting if it runs natively though :) It's actually a fairly quick thing to try out thanks to CI setup: https://github.com/valhalla/valhalla/blob/74c45e20fcc21a31c539c452c13f69d69bdfeedd/.circleci/config.yml#L146-L170

to install deps: https://github.com/valhalla/valhalla/blob/74c45e20fcc21a31c539c452c13f69d69bdfeedd/.circleci/config.yml#L10-L13

nemosmithasf commented 3 years ago

I'm running into this problem as well. (qemu: uncaught target signal 11 (Segmentation fault))

Based on the prior conversation, am I correct in understanding there's nothing that can be done until Docker fixes things on their end? (at least solutions that's beginner friendly)

nilsnolde commented 3 years ago

I do know impound can build Valhalla natively though and it works. Have a look at https://github.com/valhalla/valhalla, there’s even a section for M1. Much more involved but still fairly straight forward.

nemosmithasf commented 3 years ago

Alright, I'll check it out. Thanks for the tip.

fiotbl commented 2 years ago

Hi, I am having the same issue

2022/05/11 10:20:15.059974 [INFO] Start stage = initialize End stage = build

qemu: uncaught target signal 11 (Segmentation fault) - core dumped

/valhalla/scripts/configure_valhalla.sh: line 172:   146 Segmentation fault      valhalla_build_tiles -c ${CONFIG_FILE} -e build ${files}

Has anyone figured out a solution or is this an issue that can't be fixed with macs M1 chips?

nilsnolde commented 2 years ago

I think someone needs to step up to provide a cross-compiled arm64 Apple silicon version of the image. Valhalla is being compiled based on x64, that will never work for your architecture. It should be really simple, using qemu. However, we have no need for that, so it needs to come from the community (incl maintenance).

nilsnolde commented 2 years ago

Or someone pays for it of course, then I’d look into it too.