Today I found on GitHub a repository containing some samples for learning how to use Cesium 3D Tiles (https://github.com/AnalyticalGraphicsInc/3d-tiles-samples).
The sample we’re trying to run is the sample with the trees:
Getting the samples running on a machine can be a complicated task, because all the development dependencies have to be installed correctly.
With some Docker magic getting the samples up and running will be really easy, so let’s investigate how to do this.
When inspecting the code (see https://github.com/AnalyticalGraphicsInc/3d-tiles-samples), its clear that it’s a Node.js app (see package.json), running on port 8003 (see server.js).
I’ve forked the repository (see https://github.com/bertt/3d-tiles-samples), and made the following changes:
– added index.html (https://github.com/bertt/3d-tiles-samples/blob/master/index.html), containing the sample app;
– added a Dockerfile (see https://github.com/bertt/3d-tiles-samples/blob/master/Dockerfile)
The Dockerfile does the following things:
– It’s based on node:10 image;
– it copies package.json and runs ‘npm install’ to get all the dependencies;
– It copies the application files (index.html, index.js, server.js and a tileset with trees)
– It opens port 8004 (the sample now will run on 8004 instead of 8003 as before)
– It starts the application (with ‘npm start’)
To build the image run on a terminal:
$ docker build -t bertt/cesium_trees .
To run the image:
$ docker run -it -p 8004:8004 bertt/cesium_trees
Navigate to http://localhost:8004 and the application will show up:
The Docker image is published on Docker hub (https://hub.docker.com/r/bertt/cesium_trees) so you can also get the application from there.