acalcutt / tileserver-gl

Vector and raster maps with GL styles. Server side rendering by Mapbox GL Native. Map tile server for Mapbox GL JS, Android, iOS, Leaflet, OpenLayers, GIS via WMTS, etc.
https://tileserver-gl.readthedocs.io/en/latest/
Other
5 stars 3 forks source link

Compile and Run Locally #7

Closed boldtrn closed 2 years ago

boldtrn commented 2 years ago

I just tried to run tileserver-gl locally without Docker. Building the Docker image locally also failed.

For the local run, I think I would have to install quite a lot of dependencies, so it would be great if the docker build would work. (MacOS doesn't include X11 by default)

The Docker build failed as well. I think this is because I am on a machine with ARM CPU (Apple Silicon).

npm ERR! code 1
npm ERR! path /usr/src/app/node_modules/canvas
npm ERR! command failed
npm ERR! command sh /tmp/install-6cd65663.sh
npm ERR! Failed to execute '/usr/local/bin/node /usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js configure --fallback-to-build --update-binary --module=/usr/src/app/node_modules/canvas/build/Release/canvas.node --module_name=canvas --module_path=/usr/src/app/node_modules/canvas/build/Release --napi_version=8 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v93' (1)
npm ERR! node-pre-gyp info it worked if it ends with ok
npm ERR! node-pre-gyp info using node-pre-gyp@1.0.10
npm ERR! node-pre-gyp info using node@16.17.0 | linux | arm64
npm ERR! node-pre-gyp http GET https://github.com/Automattic/node-canvas/releases/download/v2.9.3/canvas-v2.9.3-node-v93-linux-glibc-arm64.tar.gz
npm ERR! node-pre-gyp ERR! install response status 404 Not Found on https://github.com/Automattic/node-canvas/releases/download/v2.9.3/canvas-v2.9.3-node-v93-linux-glibc-arm64.tar.gz 
npm ERR! node-pre-gyp WARN Pre-built binaries not installable for canvas@2.9.3 and node@16.17.0 (node-v93 ABI, glibc) (falling back to source compile with node-gyp) 

I was running the Docker build with:

docker build -f Dockerfile .
acalcutt commented 2 years ago

I dont think it is possible to run on arm quite yet. this relies on maplibre-native binaries, which right now are only generated for Ubuntu 20.04 X64 and macos 12 X64.. without those binaries the build of tileserver will fail.

in the maplibre-native github, we plan to eventually build some m1 binaries, so eventually it should work once we get thise binaries made.

acalcutt commented 2 years ago

unfortunately, github has no arm64 m1 runners yet, so i have no way to generate the binaries in my @acalcutt\maplibre-native.

in the official repo they have a aws m1 runner, so it should be possible to generate them there.

acalcutt commented 2 years ago

If you look at the workflow we are working on at https://github.com/maplibre/maplibre-gl-native/pull/459 you can see the steps needed to build the arm64 binaries.

acalcutt commented 2 years ago

although looking at your error, it doesn't look like canvas is ready yet either. i wonder if the latest canvas can get past that particular error.

mnutt commented 2 years ago

Huh, this is actually one I hadn't considered...for supporting tileserver-gl inside a docker container on M1, I guess we'd need linux-arm64 as well as darwin-arm64...

acalcutt commented 2 years ago

It looks like it could be possible to force docker to build a x64 image instead of letting it default to arm64. https://www.reddit.com/r/docker/comments/qyzwxo/limitations_on_docker_on_apple_m1_apple_silicon/

acalcutt commented 2 years ago

Maybe something like docker buildx build --platform linux/amd64 -t tileserver-gl .

boldtrn commented 2 years ago

Thanks for doing that much reasearch! I knew about the --platform flag, but I wasn't aware that there is a separate build command buildx which supports building a different platform. So with this command it's possible to build an amd64 image locally and the build works fine and I can run the container.

acalcutt commented 2 years ago

So that worked, awesome. buildx is new to me too, but all the examples I saw that used --platform seemed to use it, so it was a good guess...haha

acalcutt commented 2 years ago

I have added arm64 maplibre binaries to my tileserver-gl release, so it should no longer require compiling at x64 to run.