diff --git a/README.md b/README.md index f214e27..9219b4d 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ All information, thought, and code described here is intended for informational ## Nightscout on Docker This repository will contain all the configuration files for running Nightscout on a Docker environment. Docker enables the end-user to easily deploy and manage the Nightscout stack on top of a cloud-providers such as SoftLayer, Azure, Digital-Ocean, Amazon Web Services or a private server (Bring Your Own Node). -[![Docker Registry](http://dockeri.co/image/nightscout/cgm-remote-monitor-development)](https://registry.hub.docker.com/u/nightscout/cgm-remote-monitor-development/) +[Docker Hub - Nightscout](https://registry.hub.docker.com/u/nightscout/cgm-remote-monitor-development/) ## Getting started using Docker @@ -17,9 +17,9 @@ This repository will contain all the configuration files for running Nightscout An easy way to deploy and maintain your Docker environment is using Tutum. Tutum provides an user friendly interface for managing the Docker environment running on the cloud provider, which can either be [Amazon Web Services (AWS)](http://aws.amazon.com/), [Digital Ocean (DO)](https://www.digitalocean.com/), [SoftLayer](http://www.softlayer.com/) or [Microsoft Azure](http://azure.microsoft.com/). For this tutorial also provides steps to confugure [Amazone Web Services](cloudprovider/aws.md) and [Digital Ocean](cloudprovider/do.md) which are both quite easy to configure. You will require at least one of the services. -To stack configuration is written in a [Docker Compose](https://docs.docker.com/compose/) (which is the successor of [Fig](http://www.fig.sh/)) compatible language. Please do not forget to change the `API_SECRET` and the MongDB password in `MONGO_CONNECTION` and `MONGODB_PASS` in the environment variables. +The stack configuration is written in a [Docker Compose](https://docs.docker.com/compose/) (which is the successor of [Fig](http://www.fig.sh/)) compatible language. Please do not forget to change the `API_SECRET` and the MongDB password in `MONGO_CONNECTION` and `MONGODB_PASS` in the environment variables. -Currently this deploys the [development branch of the project](https://github.com/fokko/cgm-remote-monitor) as it is not yet wired with the nightscout repository. But this will possibly fixed in the foreseeable future as a collaborator will configure it on the Nightscout repository. Every time a commit is pushed on the branch, the [Docker-hub](https://registry.hub.docker.com/u/fokkodriesprong/cgm-remote-monitor/) will build a new version of the image using a hook on the Github repository. +Currently this deploys the [development branch of the project](https://github.com/fokko/cgm-remote-monitor) as it is not yet wired with the nightscout repository. This will possibly fixed in the foreseeable future as a collaborator will configure it on the Nightscout repository. Every time a commit is pushed on the branch, the [Docker-hub](https://registry.hub.docker.com/u/fokkodriesprong/cgm-remote-monitor/) will build a new version of the image using a hook on the Github repository. Hit the button to deploy the stack as defined in `docker-compose.yml`. @@ -45,12 +45,16 @@ If you have any idea's, don't hesitate to contact me. ### Deploying the stack using Docker compose. -To stack configuration is written in a [Docker Compose](https://docs.docker.com/compose/) (which is the successor of [Fig](http://www.fig.sh/)). Deploying is quick and easy: +** Note: ** This requires Docker Compose 1.5 or greater. Ensure you're running an up-to-date version before running these commands. + +To stack configuration is written in a [Docker Compose](https://docs.docker.com/compose/) (which is the successor of [Fig](http://www.fig.sh/)). Unique passwords and API keyss are generated by running the `envgen.sh script`. Deploying is quick and easy: ```bash git clone https://github.com/nightscout/nightscout-docker.git cd nightscout-docker +. ./envgen.sh docker-compose up ``` +The API key and MongoDB passwords are automatically generated. Simply scroll to the top of the log output and you will be able to see a copy of them. If you want to use your own, edit the docker-compose.yml file and replace the `${MONGODB_PASS}` and `${NIGHTSCOUT_APIKEY}` with your own values. -All images will be pulled from the registry and started by Docker. \ No newline at end of file +All images will be pulled from the registry and started by Docker. \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index e619073..f422a79 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,3 +1,7 @@ +##### NOTE ####### +# This docker compose file requires docker compose 1.5 to be installed +# before calling docker-compose, ensure you've ready the Readme file first + broker: image: 'prologic/mosquitto:latest' ports: @@ -5,18 +9,23 @@ broker: database: image: 'tutum/mongodb:latest' environment: - - MONGODB_PASS={{** CHANGE ME **}} - ports: - - '27017:27017' + - MONGODB_PASS:${MONGODB_PASS} + +# Uncomment if you want to expose the MongoDB port directly +# If you're using the API interface (highly recommended) then you can +# safely leave this commented out +# ports: +# - '27017:27017' + nightscout: image: 'nightscout/cgm-remote-monitor-development:latest' environment: - - API_SECRET={{** CHANGE ME **}} - - 'MONGO_CONNECTION=mongodb://admin:{{** CHANGE ME **}}@database/admin' - - 'MQTT_MONITOR=mqtt://{{** CHANGE ME **}}@broker' - - PORT=1337 + - API_SECRET:${NIGHTSCOUT_APIKEY} + - 'MONGO_CONNECTION=mongodb://admin:${MONGODB_PASS}@database/admin' + - 'MQTT_MONITOR=mqtt://${MQTT_USER}@broker' + - PORT:1337 links: - broker - database ports: - - '1337:1337' \ No newline at end of file + - '1337:1337' diff --git a/envgen.sh b/envgen.sh new file mode 100755 index 0000000..9488357 --- /dev/null +++ b/envgen.sh @@ -0,0 +1,22 @@ +#!/bin/bash +# This script generates a unique password for the API Key, the MongoDB password and MQTT Username +# To use it, ensure you use . ./envgen.sh (noting the first dot) to set the variables for the current shell +# Then, simply run docker-compose up +echo "" +echo "" +echo "Generating API key and MongoDB password..." +echo "========================================================================================" + +# Generate passwords +export NIGHTSCOUT_APIKEY=`docker run --rm timbutler/simplepass 12 1` +export MONGODB_PASS=`docker run --rm timbutler/simplepass 12 1` +export MQTT_USER=`docker run --rm timbutler/simplepass 8 1` + +# Print to the screen for reference +echo "Nightscout API key: $NIGHTSCOUT_APIKEY" +echo "MongoDB Admin Password: $MONGODB_PASS" +echo "MQTT User: $MQTT_USER" +echo "========================================================================================" +echo "" +echo "Now you can run "docker-compose up" to build and start the Docker containers" +echo "" \ No newline at end of file