diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..548a6a8 --- /dev/null +++ b/Dockerfile @@ -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 diff --git a/README.md b/README.md index aa397c3..0c81b05 100644 --- a/README.md +++ b/README.md @@ -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 git@github.com: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. @@ -176,5 +208,3 @@ Runs a linter, prettier, and auto-formats code to meet consistent style, while c ```sh npm run lint ``` - -