This document describes making a self hosted nightscout instance, with Docker on Oracle Free Tier. The instance will use SSL encryption using certificates from Let's Encrypt.
This will require a working domain name with the ability to create sub-domains.
Sign up for an Oracle Cloud Free Tier account: https://www.oracle.com/ca-en/cloud/free/
Follow this guide to signup for an Oracle Cloud account: https://k21academy.com/oracle-cloud/video-register-free-oracle-cloud-trial-account/
- You'll need to provide a credit card to activate your account.
- You will never be charged for services unless you explicitly upgrade your account.
The tutorials below will guide you thorugh how to create a Virtual Machine instance using Oracle Cloud Infrastructure Compute Service.
It is uneecessary to dedicate all the compute provide by OCI to one instance of Nightscout, I recommend the following settings:
-
Image: Canonical Ubuntu version 22.04
-
Shape: Ampere
- Shape Name: VM.Standard.A1.Flex
- Number of OCPUs: 1
- Amount of Memory (GB): 6
A firewall rule will be required to allow access to your Virtual Machine instance.
You are looking to update the Defaul Security List, this can be accessed in a number of ways:
- Home -> Compute -> Instances
- Select your instance name
- Select your subnet under Primary VNIC
- Then select the Security List
- Home -> Networking -> Virtual Cloud Networks
- Select your VCN
- Select the subnet
Once you are at the security list, you can add an additional rule:
- Click on Add Ingress Rules
- Source Type: CIDR
- Source CIDR: 0.0.0.0/0
- IP Protocol: TCP
- Destination Port Range: 443
- Description: Allow https access to Nightscout
Now that you have a an Ubuntu server running, it's time to install and configure docker.
- Once the virtual machine is up and running, it's good practice to perform some initial updates:
sudo apt-get update && sudo apt-get upgrade
- The Docker documentation has great installation guide: https://docs.docker.com/engine/install/ubuntu/, follow it closely
- Once Docker is installed successfully, make sure to follow the Post-installation steps for Linux: https://docs.docker.com/engine/install/linux-postinstall/
- Ensure you focus on the following:
- Manage Docker as a non-root user
- Configure Docker to start on boot
I tend to place all my docker configurations in the /data directory.
- Create a new /data directory:
sudo mkdir /data
- Change the directory group owner:
sudo chgrp ubuntu /data
- Change group permissions on the directory:
sudo chgrp ubuntu /data
- Create a directory for nightscout
mkdir /data/nightscout
Docker and Docker Compose will be used to seamlessly provision all components necessary to run a self-hosted Nightscout instance.
The following components will be defined in the Docker Compose configuration file, with configuration settings being pulled from an environment variable file.
- CGM-Remote-Monitor (Nightscout)
- mongodb: acts as the database for Nightscout data
- traefik: traefik is a docker native reverse proxy that will forward requests to the nightscout docker container. Traefix additionally provides SSL certificats via Let's Encrypt.
We will be using Docker Compose to define all the Nightscout configuration settings.
We will define most configuration settings in environment variable file local to the docker compose file. Copy the sample.env file to the /data/nightscout folder and rename the file to .env.