Skip to content

Instantly share code, notes, and snippets.

@afly007
Last active June 5, 2025 09:00
Show Gist options
  • Save afly007/6187663ad1cc67d534c397eb09c33b8f to your computer and use it in GitHub Desktop.
Save afly007/6187663ad1cc67d534c397eb09c33b8f to your computer and use it in GitHub Desktop.

Self Hosted Nightscout on Oracle Cloud Free Tier

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.

Oracle Cloud Setup

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.

Set up your Virtual Machine instance

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:

Configure your Virtual Cloud Network

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:

  1. Home -> Compute -> Instances
  • Select your instance name
  • Select your subnet under Primary VNIC
  • Then select the Security List
  1. 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

Ubuntu Docker Host

Now that you have a an Ubuntu server running, it's time to install and configure docker.

Install 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

Set up your working environment

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

Running Nightscout with Docker

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.

Prepare Nightscout Docker Container

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.

# Nightscout variables
API_SECRET=
BRIDGE_USER_NAME=
BRIDGE_PASSWORD=
BRIDGE_SERVER=
# AWS route53 variables
AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=
AWS_REGION=
AWS_HOSTED_ZONE_ID=
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment