Skip to content

Commit

Permalink
add Dockerfile and docs for running from container
Browse files Browse the repository at this point in the history
  • Loading branch information
morganherlocker committed Dec 6, 2019
1 parent 0613331 commit 590c28d
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 2 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
```


0 comments on commit 590c28d

Please sign in to comment.