This repo has three things.
- A data pipeline for generating offline map tiles
- A simple web server for serving tiles and some API endpoints
- A bundling and distribution script for both the web server and the game
The data pipeline uses a combination of tl
, @mapbox/mbtiles
, and tilelive-http
to scrape a Mapbox tileset.
To run the pipeline first install all three dependencies:
$ npm i -g tl @mapbox/mbtiles tilelive-http
Then make sure to have a MAPBOX_TOKEN
in your env.
$ export MAPBOX_TOKEN=<token>
Then run pipeline.sh
$ ./pipeline.sh
This will create a tiles.mbtiles
file which is used by the web server.
The web server is a simple express server with some endpoints serving static JSON (for the API responses)
and protobuf-based vector tiles out of the tiles.mbtiles
file that is generated from the data pipeline.
To start the web server run index.js
:
$ node index.js
The output of index.js
will include the API address.
To use this tile server with Civic's BaseMap
, set the low-level mapGlOptions
to override theme and
API urls:
<BaseMap
mapGLOptions={{
mapboxApiUrl: "http://localhost:3456/tiles",
mapStyle: "mapbox://styles/disaster"
}}
/>
This is handled with docker-compose.
Both this repo and the Civic repo continuously deliver docker images to Hack Oregon's Elastic Container Registry. The docker-compose.yml
file in this repo references those images by name, but expects you to provide the registry url.
To make it as easy as possible to get and start the docker images, the get-game.sh
script is available on S3. Running the latest build of the game and web server takes three steps:
- Download the script
$ curl -sO https://hacko-cdn.s3-us-west-2.amazonaws.com/earthquake-heroes/get-game.sh
-
Edit the script to provide values for the AWS environment variables. If you are meant to run the game, you'll have credentials.
-
Run the script
$ bash get-game.sh
To make it as easy as possible to get and start the docker images, the get-game.ps1
powershell script is available on S3. Running the latest build of the game and web server takes three steps:
- Download the scripts
PS:\> curl -Uri https://hacko-cdn.s3-us-west-2.amazonaws.com/earthquake-heroes/get-game.ps1 -OutFile get-game.ps1
PS:\> curl -Uri https://hacko-cdn.s3-us-west-2.amazonaws.com/earthquake-heroes/start-game.ps1 -OutFile start-game.ps1
-
Edit the script to provide values for the AWS environment variables. If you are meant to run the game, you'll have credentials.
-
Run the get-game script to pull docker containers
PS:\> & .\get-game.ps1
- Run the start-game script to run the tileserver and the game!
PS:\> & .\start-game.ps1