How to Install OnTrack Budgeting Software on Linux

A photograph of a man using a laptop.

Ontrack is a simple yet powerful self-hosted budgeting software for Linux. It works by creating a clean and beautiful interface where you can list your budget, review your finances, and even track your spending history. This article shows you how to install Ontrack on Ubuntu Linux 22.04 using Docker Compose and Caddy.

Assumption: This article assumes that you’re installing Ontrack on an Ubuntu LTS VPS with at least 2GB of RAM. It also assumes that your machine is accessible over the internet and that you own a domain name.

Obtaining the Dependencies for Ontrack

The first step in installing Ontrack budgeting software in Linux is to obtain Docker and Caddy. The former will run the entire web app in an isolated container, while the latter will allow you to broadcast it to the internet.

To start, fetch the signing key for the Docker repository from the developer’s website:

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg<br>sudo chmod a+r /etc/apt/keyrings/docker.gpg

Create a new apt repository file for Docker:

sudo nano /etc/apt/sources.list.d/docker.list

Write the following line of code inside your repository file:

deb [arch=amd64 signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu jammy stable

Download the signing key for the Caddy project repository:

curl -fsSL 'https://dl.cloudsmith.io/public/caddy/stable/gpg.key' | sudo gpg --dearmor -o /usr/share/keyrings/caddy-stable-archive-keyring.gpg

Fetch the Caddy project’s repository file by running the following command:

curl -fsSL 'https://dl.cloudsmith.io/public/caddy/stable/debian.deb.txt' | sudo tee /etc/apt/sources.list.d/caddy.list

Apply your new repositories and make sure that your system is completely up-to-date:

sudo apt update && sudo apt upgrade

Install Docker, Docker Compose, and Caddy using apt:

sudo apt install docker-ce docker-ce-cli containerd.io docker-compose-plugin docker-buildx-plugin caddy git

Good to know: learn how you can fix broken packages in Linux.

Obtaining the Ontrack Docker Container

Fetch the current Ontrack repository for Linux from the developer’s Github page:

git clone https://github.com/inoda/ontrack.git && cd ./ontrack

Run the following command twice to generate two long random strings of text:

cat /dev/urandom | tr -dc 'A-Za-z0-9' | fold -w 32 | head -n 1 >> ~/random-pass.txt
A terminal showing the two randomly generated passwords for Ontrack.

Open Ontrack’s “docker-compose.yml” file using your favorite text editor:

nano ./docker-compose.yml

Scroll to the “SECRET_KEY_BASE” variable and change the value from “super-secret” to your first random string.

A terminal highlighting the random secret key base for Ontrack.

Replace the “secret” string on the “DATABASE_URL” variable with your second random string.

A terminal highlighting the second random password for the Postgres database.

Scroll down to the “POSTGRES_PASSWORD” variable and replace the “secret” value with your second random string.

A terminal highlighting the same second password on the POSTGRES_PASSWORD variable.

Updating and Building the Ontrack Container

Open the Dockerfile for Ontrack using your favorite text editor:

nano ./Dockerfile

Replace the value of the FROM variable with the following:

FROM ruby:3.1.2-alpine
A terminal highlighting the different Ruby version for Ontrack.

Save your modified Dockerfile, then open the “package.json” file:

nano ./package.json

Find the line that starts with @babel/preset-env, then insert the following code underneath it:

"babel-plugin-macros": "^3.0.1",
A terminal showing the added dependency for Ontrack.

Scroll down to the “devDependencies” category, then add the following under the @babel/eslint-parser line:

"@babel/plugin-proposal-object-rest-spread": "^7.15.4",
A terminal showing the second dev dependency for Ontrack.

Open your instance’s configuration file using your favorite text editor:

nano ~/ontrack/config/environments/development.rb

Add the following line of code just below Rails.application.configure do:

config.hosts = [
    "SUBDOMAIN.YOUR-ROOT.DOMAIN"
]
A terminal showing the setting for the instance's hostname.

Save your instance’s config file, then run the following command to build both Ontrack and its Postgres database:

sudo docker compose up --detach

Note: The build process for the Ontrack Docker container can take between 5 to 10 minutes depending on your server’s resources. If your machine has less than 2GB of RAM and no swapfile, Docker will fail without reporting any errors on the terminal.

Confirm that the Ontrack containers are running properly by listing all the active Docker processes:

sudo docker ps
A terminal showing the two Docker containers running Ontrack.

Creating an SSL Reverse Proxy with Caddy

At this point, you have a running Ontrack budgeting software on your machine’s port 3000. To access this securely, you need to create an SSL reverse proxy that encrypts the connection between you and your server.

Go to your domain’s DNS manager, then add a new “A” record for your Ontrack instance.

A screenshot showing the custom A DNS record for Ontrack.

Backup the original Caddyfile, then create a new Caddyfile under “/etc/caddy/”:

sudo mv /etc/caddy/Caddyfile ~/Caddyfile.backup
sudo nano /etc/caddy/Caddyfile

Paste the following block of code inside your new Caddyfile:

SUBDOMAIN.YOUR-ROOT.DOMAIN {
    reverse_proxy :3000
}

Save your new Caddyfile, then start the Caddy daemon to run your new reverse proxy:

sudo systemctl enable --now caddy.service

Test if your SSL reverse proxy is working by navigating to your URL.

A screenshot showing the Ontrack instance working properly.

Good to know: learn more about SSL and how it protects the web from malicious actors by issuing your own self-signed certificate in OpenSSL.

Using Ontrack and Creating a User Account

With Ontrack up and running, you can now create your user account. To do this, go back to your server’s terminal window then open the shell for the Ontrack container:

sudo docker exec -it ontrack sh

Open the database handler inside your Ontrack container:

bundle exec rails c

Create your new user account by running the following command:

User.create!(username: "YOUR-USERNAME", password: "YOUR-SECURE-PASSWORD")
A terminal showing a sample user's credentials.

Type “exit”, then press Enter to leave the database handler.

Press Ctrl + D to leave your Docker container’s root shell.

A terminal showing the exit process for the Ontrack Docker container.

Test your new account by opening Ontrack on your web browser and logging in to your account.

Creating Your First Transaction on Ontrack

To use Ontrack for logging transactions, you need to create an expense category. This allows the web app to collate your expenses in groups, which makes it easier to infer insights into your spending habits.

Scroll down the Ontrack dashboard, then click Add a category.

A screenshot showing the "Add a category" button on the Ontrack budgeting software for Linux.

Provide the category’s name, the tag color, and whether or not it has a spending limit. For instance, I’ve labeled mine as “Leisure” with a red tag and a limit of $200.

A screenshot showing the details of a sample category in Ontrack.

Click Add an expense on the Ontrack Dashboard.

A screenshot showing the "Add an expense" button on the Ontrack dashboard.

Fill in the details of your expense, then click Save to commit it to your Ontrack instance.

A screenshot showing the expenses form for Ontrack.

Lastly, confirm that Ontrack has successfully saved your transaction by checking your expense history. To do that, scroll up the page, then click the History link on the page’s upper right corner.

A screenshot showing a sample transaction in Ontrack's history.

Installing and deploying your own expense tracker software is just the first step in taking back control over your online and digital life. Learn how you can ensure your privacy when sending emails by installing an alias server like SimpleLogin.

Image credit: Campaign Creators via Unsplash and Ontrack Github. All alterations and screenshots by Ramces Red.

Subscribe to our newsletter!

Our latest tutorials delivered straight to your inbox

Ramces Red
Ramces Red - Staff Writer

Ramces is a technology writer that lived with computers all his life. A prolific reader and a student of Anthropology, he is an eccentric character that writes articles about Linux and anything *nix.