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

Minimal maplibre-gl-native changes + docker build update #602

Merged
merged 10 commits into from
Sep 16, 2022

Conversation

acalcutt
Copy link
Collaborator

@acalcutt acalcutt commented Sep 15, 2022

These are minimal changes to switch tileserver-gl to use maplibre-gl-native and maplibre-gl-style-spec.

After this change, the OS in the docker images requires an update to support the maplibre-gl-native binaries which are built on ubuntu-20.04

I have also updated the dependencies in the documentation to match what is needed for maplibre-gl-native

Without any other changes, it seems this works on node 10 - node 16. node 18 failed

@petrsloup petrsloup self-requested a review September 15, 2022 06:31
@roblabs
Copy link

roblabs commented Sep 15, 2022

Thanks, @acalcutt for the upgrades and for pushing this forward.


I gave the fork a spin, WifiDB:maplibre-native, but I was not able to get the Dockerfile to run and serve Zurich MBTiles.

  • The Docker build works
  • The Docker server appears to be running (log below)
  • Firefox reports "The connection was reset".

I'm using my usual tileserver-gl usage steps.

Maybe I'm missing a step?!?


# 1. edit, but don't commit, simple changes to `package.json` to expose version of your local build

# 2. Make a local Docker image
docker build -t tileserver-gl .

# 3.  Use that local Docker image
#     `zurich_switzerland.mbtiles` already in root folder
docker run --rm -it -v $(pwd):/data -p 8080:80 tileserver-gl --verbose

# 
open http://localhost:8080

Docker log

Server appears to be running fine. changed the name in package.json to verify which Docker image I'm using.

Starting tileserver-gl-locallybuilt v3.1.1
No MBTiles specified, using zurich_switzerland.mbtiles
[INFO] Automatically creating config file for zurich_switzerland.mbtiles
[INFO] Only a basic preview style will be used.
[INFO] See documentation to learn how to create config.json file.
{
"options": {
"paths": {
"root": "/app/node_modules/tileserver-gl-styles",
"fonts": "fonts",
"styles": "styles",
"mbtiles": "/data"
}
},
"styles": {
"basic-preview": {
"style": "basic-preview/style.json",
"tilejson": {
"bounds": [
8.275,
47.225,
8.8,
47.533
]
}
}
},
"data": {
"v3": {
"mbtiles": "zurich_switzerland.mbtiles"
}
}
}
Starting server
Listening at http://[::]:8080/
Startup complete

@acalcutt
Copy link
Collaborator Author

acalcutt commented Sep 15, 2022

Maybe download the mbtiles first. I seem to remember in the docker it wasn't able to download to the current directory

wget https://github.com/acalcutt/tileserver-gl/releases/download/test_data/zurich_switzerland.mbtiles
docker run --rm -it -v $(pwd):/data -p 8080:80 tileserver-gl --verbose

@acalcutt
Copy link
Collaborator Author

acalcutt commented Sep 15, 2022

In https://github.com/acalcutt/tileserver-gl/ I actually had made that part of the directions for docker. If running it straight with node the download works, but in the docker I don't think it wasn't able to write back to the data directory to save the file.

Example using a mbtiles file

wget https://github.com/acalcutt/tileserver-gl/releases/download/test_data/zurich_switzerland.mbtiles
docker run --rm -it -v $(pwd):/data -p 8080:80 wifidb/tileserver-gl --mbtiles zurich_switzerland.mbtiles
[in your browser, visit http://[server ip]:8080]

Example using a config.json + style + mbtiles file

wget https://github.com/acalcutt/tileserver-gl/releases/download/test_data/test_data.zip
unzip test_data.zip
docker run --rm -it -v $(pwd):/data -p 8080:80 wifidb/tileserver-gl
[in your browser, visit http://[server ip]:8080]

@acalcutt
Copy link
Collaborator Author

acalcutt commented Sep 15, 2022

Oh, actually I think it is the port it is coming up on. it is starting on 8080 but the command is saying it is on 80

try
docker run --rm -it -v $(pwd):/data -p 8080:8080 tileserver-gl --verbose

The missing mbtiles file would give an error like this, and you arn;t seeing that

root@mapgen2:/opt/test3/tileserver-gl# docker run --rm -it -v $(pwd):/data -p 8080:8080 tileserver-gl --verbose
Starting tileserver-gl v3.1.1
No MBTiles found
[DEMO] Downloading sample data (zurich_switzerland.mbtiles) from https://github.com/maptiler/tileserver-gl/releases/download/v1.3.0/zurich_switzerland.mbtiles
node:events:491
      throw er; // Unhandled 'error' event
      ^

Error: EACCES: permission denied, open 'zurich_switzerland.mbtiles'
Emitted 'error' event on WriteStream instance at:
    at WriteStream.onerror (node:internal/streams/legacy:62:12)
    at WriteStream.emit (node:events:513:28)
    at WriteStream.emit (node:domain:489:12)
    at emitErrorNT (node:internal/streams/destroy:157:8)
    at emitErrorCloseNT (node:internal/streams/destroy:122:3)
    at processTicksAndRejections (node:internal/process/task_queues:83:21) {
  errno: -13,
  code: 'EACCES',
  syscall: 'open',
  path: 'zurich_switzerland.mbtiles'
}

@acalcutt
Copy link
Collaborator Author

acalcutt commented Sep 15, 2022

I added "-p 80" to docker-entrypoint.sh so it starts on 80 inside docker like the old release did. I think now it should work with the instuctions you have and site documentation.

Not sure how it used to start on port 80, since it looks like tileserver defaults to 8080 and there wasn't a port set in docker-entrypoint.sh before.

EDIT: I see it was set here.
https://github.com/maptiler/tileserver-gl/blob/master/Dockerfile#L55
not sure why that no longer works since I really didn't change that piece

@roblabs
Copy link

roblabs commented Sep 15, 2022

@acalcutt — Thanks for the pointing out the port and the patch. I was successful using your steps.

It now works from both your Docker Hub image & a locally built Docker image.

Thanks!


# Tested with Docker Hub image `wifidb/tileserver-gl`
#  note:  this will change when maptiler accepts the PR
docker run --rm -it -v $(pwd):/data -p 8080:80 wifidb/tileserver-gl

Starting @acalcutt/tileserver-gl v4.0.22
Using specified config file from config.json
Starting server
Listening at http://[::]:80/
Startup complete


# Make a local Docker image
docker build -t tileserver-gl .
# Tested with locally built Docker image `tileserver-gl`
docker run --rm -it -v $(pwd):/data -p 8080:80 tileserver-gl --verbose

Starting tileserver-gl-LOCALLY-BUILT v3.1.1β


Test on localhost:8080 using Docker Hub & locally built Docker image
image

@petrsloup
Copy link
Member

Thanks for the effort !

Tested locally and everything seems to be working fine now, so I'm merging this PR 👍

I was also thinking about the Dockerfile, which got a little too complicated over time.. Maybe it would make sense to base it on ubuntu (and install node inside) rather than the node image (which is based on debian), so that we can more easily install all the deps from apt instead of hardcoding the .deb urls. But I guess that would require some more experimentation..

@petrsloup petrsloup merged commit 235b2b7 into maptiler:master Sep 16, 2022
@acalcutt
Copy link
Collaborator Author

I did explorer a few different docker images other than one I chose, but I forget why I decided to go that route. I feel like it was a OS + Node combination I was trying to get but couldn't find already made.

@pgassmann
Copy link

pgassmann commented Sep 16, 2022

Thank you @acalcutt for the updates and @petrsloup for merging this. I already feared this project is unmaintained as the last image on dockerhub is from 2 years ago. I was looking for alternatives and switched to the wifidb image yesterday ;-)

When will you release a new official image?

@acalcutt
Copy link
Collaborator Author

I can't speak for when this is released, but I have suggested taking our time releasing this

Currently there is one known bug a static image rendering I am trying to work out with the maplibre-native team here maplibre/maplibre-native#479. the issue with static tiles looks like this ( acalcutt#5 ). I have a custom maplibre-native fix in my fork which seems to fix it, but it seems to break macos builds....so we are still looking at that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

4 participants