Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 50 additions & 0 deletions add.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#!/bin/sh

while [[ ! "$subdomain" =~ ^[a-zA-Z0-9-]+$ ]]; do
echo
echo "Enter the name of the subdomain where your Nightscout will be available:"
read subdomain
done
secret=$(cat /proc/sys/kernel/random/uuid)

cat >> docker-compose.yml <<EOF

nightscout-${subdomain}:
image: nightscout/cgm-remote-monitor:latest
container_name: nightscout-${subdomain}
restart: always
depends_on:
- mongo
labels:
- 'traefik.enable=true'
- 'traefik.http.routers.nightscout-${subdomain}.rule=Host(\`${subdomain}.\${NS_DOMAIN}\`)'
- 'traefik.http.routers.nightscout-${subdomain}.entrypoints=web'
- 'traefik.http.routers.nightscout-${subdomain}.entrypoints=websecure'
- 'traefik.http.routers.nightscout-${subdomain}.tls.certresolver=le'
logging: *default-logging
environment:
<<: *ns-common-env
CUSTOM_TITLE:
API_SECRET: '${secret}'
AUTH_DEFAULT_ROLES: denied
BRIDGE_USER_NAME:
BRIDGE_PASSWORD:
BRIDGE_SERVER: EU
MONGO_CONNECTION: mongodb://mongo:27017/ns-${subdomain}
ENABLE: basal iob cob boluscalc cage sage iage bage pump openaps pushover bgi food rawbg bridge
SHOW_PLUGINS: basal iob cob boluscalc cage sage iage bage pump openaps pushover bgi food rawbg

EOF

sudo docker compose up -d

echo "URL: $subdomain.$domain"
echo "API_SECRET for Nightscout access (write it down!): $secret"
echo
echo "You can view and edit your API_SECRET and other configurations by 'nano docker-compose.yml'"
echo "Email address and domain variables are stored in '.env'"
echo
echo "To add more Nightscout instances,"
echo "please run 'bash <(wget -qO- https://raw.githubusercontent.com/justmara/ns-setup/main/add.sh)'"
echo
echo "After editing settings, re-launch your Nightscout app by typing 'sudo docker compose up -d'"
77 changes: 24 additions & 53 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,25 @@
version: '3'
version: '3.9'

x-ns-common-env: &ns-common-env
NODE_ENV: production
INSECURE_USE_HTTP: 'true'
TZ: Europe/Moscow
TIMEZONE: Europe/Moscow
TIME_FORMAT: 24
DEVICESTATUS_ADVANCED: 'true'
DISPLAY_UNITS: mmol
LANGUAGE:
OPENAPS_COLOR_PREDICTION_LINES: 'true'
PUMP_FIELDS: clock reservoir
SHOW_FORECAST: openaps
THEME: colors

x-logging:
&default-logging
options:
max-size: '10m'
max-file: '5'
driver: json-file

services:
mongo:
Expand All @@ -7,57 +28,7 @@ services:
container_name: mongo
volumes:
- ${NS_MONGO_DATA_DIR:-./mongo-data}:/data/db:cached

nightscout:
image: nightscout/cgm-remote-monitor:latest
container_name: nightscout
restart: always
depends_on:
- mongo
labels:
- 'traefik.enable=true'
# Change the below Host from `localhost` to be the web address where Nightscout is running.
# Also change the email address in the `traefik` service below.
- 'traefik.http.routers.nightscout.rule=Host(`${NS_DOMAIN}`)'
- 'traefik.http.routers.nightscout.entrypoints=websecure'
- 'traefik.http.routers.nightscout.tls.certresolver=le'
environment:
### Variables for the container
NODE_ENV: production
TZ: Etc/UTC

### Overridden variables for Docker Compose setup
# The `nightscout` service can use HTTP, because we use `traefik` to serve the HTTPS
# and manage TLS certificates
INSECURE_USE_HTTP: 'true'

# For all other settings, please refer to the Environment section of the README
### Required variables
# MONGO_CONNECTION - The connection string for your Mongo database.
# Something like mongodb://sally:sallypass@ds099999.mongolab.com:99999/nightscout
# The default connects to the `mongo` included in this docker-compose file.
# If you change it, you probably also want to comment out the entire `mongo` service block
# and `depends_on` block above.
MONGO_CONNECTION: mongodb://mongo:27017/ns

# API_SECRET - A secret passphrase that must be at least 12 characters long.
API_SECRET: ${NS_SECRET}

### Features
# ENABLE - Used to enable optional features, expects a space delimited list, such as: careportal rawbg iob
# See https://github.com/nightscout/cgm-remote-monitor#plugins for details
ENABLE: basal iob cob boluscalc cage sage iage bage pump openaps pushover bgi food rawbg
SHOW_FORECAST: openaps
PUMP_FIELDS: clock reservoir
DISPLAY_UNITS: mmol

# AUTH_DEFAULT_ROLES (readable) - possible values readable, denied, or any valid role name.
# When readable, anyone can view Nightscout without a token. Setting it to denied will require
# a token from every visit, using status-only will enable api-secret based login.
AUTH_DEFAULT_ROLES: denied

# For all other settings, please refer to the Environment section of the README
# https://github.com/nightscout/cgm-remote-monitor#environment
logging: *default-logging

traefik:
image: traefik:latest
Expand All @@ -72,11 +43,11 @@ services:
- "--certificatesresolvers.le.acme.httpchallenge=true"
- "--certificatesresolvers.le.acme.httpchallenge.entrypoint=web"
- '--certificatesresolvers.le.acme.storage=/letsencrypt/acme.json'
# Change the below to match your email address
- '--certificatesresolvers.le.acme.email=${NS_EMAIL}'
ports:
- '443:443'
- '80:80'
volumes:
- './letsencrypt:/letsencrypt'
- '/var/run/docker.sock:/var/run/docker.sock:ro'
logging: *default-logging
15 changes: 2 additions & 13 deletions ns-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,26 +23,15 @@ sudo docker run hello-world
echo Okay, lets set up some variables
echo
echo "Enter you email (the one SSL certificate will be generated for):"
echo "Введите ваш email (на него будет зарегистрирован SSL-сертификат):"
read email
echo "NS_EMAIL=$email" >> .env
echo

echo Now enter domain name you Nightscout will be hosted at:
echo Введите имя домена, на котором ваш Nightscout будет доступен:
echo Now enter the domain name you Nightscout will be hosted at, excluding the subdomain:
read domain
echo "NS_DOMAIN=$domain" >> .env
echo

secret=$(cat /proc/sys/kernel/random/uuid)
echo "NS_SECRET=$secret" >> .env

curl https://raw.githubusercontent.com/justmara/ns-setup/main/docker-compose.yml --output docker-compose.yml

sudo docker compose up -d

echo "Your secret for Nightscout access (write it down!):"
echo "Ваш секретный ключ для доступа к Nightscout (запишите!):"
echo "secret: $secret"
echo "email: $email"
echo "domain: $domain"
bash <(wget -qO- https://raw.githubusercontent.com/justmara/ns-setup/main/add.sh)