Skip to content

Commit

Permalink
Merge pull request sharedstreets#102 from sharedstreets/docker
Browse files Browse the repository at this point in the history
Docker
  • Loading branch information
morganherlocker authored Dec 6, 2019
2 parents 77d7a2e + 12372fa commit ca50a27
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 4 deletions.
7 changes: 7 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
FROM node:11

ENV NPM_CONFIG_PREFIX=/home/node/.npm-global
ENV PATH=$PATH:/home/node/.npm-global/bin

USER node
RUN npm install -g mobility-metrics
34 changes: 32 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,38 @@ The CLI is responsible for downloading raw data, running aggregation and reports
mobility-metrics --config ./example/example.json --public ./public --cache ./cache --day 2019-07-20;
```

## Docker

Docker is supported, and is recommended when installation is challenging on bespoke systems that fail when installing dependencies, such as OSRM.

### Building a docker image

```sh
# clone repo
git clone [email protected]:sharedstreets/mobility-metrics.git
cd mobility-metrics

# build image
docker build --tag mobility-metrics-image .
```

### Running mobility-metrics from docker image

Once you have a docker image built, use mobility-metrics CLI from within the image using `docker run`. In this example, a config file exists in the current directory, which mobility-metrics can read using the mounted volume.

```sh
docker run -it --rm \
-v $PWD:/data/ \ # mount current working directory to image volume
mobility-metrics-image \
mobility-metrics \
--config /data/config.json \
--public /data/public \
--cache /data/cache \
--startDay 2019-09-20 \
--endDay 2019-09-20 \
--reportDay 2019-09-20;
```

## Serving API

The metrics data and reports generated by the mobility-metrics CLI are intended to be served from a static HTTP server, such as apache, nginx, or a public HTTP service like netifly or Github Pages. See the gh-pages branch of this repository to see how the demo for this tool is hosted using simulated data in Nashville, TN.
Expand Down Expand Up @@ -176,5 +208,3 @@ Runs a linter, prettier, and auto-formats code to meet consistent style, while c
```sh
npm run lint
```


2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "mobility-metrics",
"version": "4.0.0",
"version": "4.2.0",
"description": "tools for aggregating mobility data",
"bin": "./src/cli.js",
"scripts": {
Expand Down

0 comments on commit ca50a27

Please sign in to comment.