Network registration

Before the Pi can gain full network access, it needs to be added as a Hallnet device using the university’s web service. You’ll need the Pi’s MAC address, which should be shown if you boot the Pi with no bootable media and connect it to a display.

Of course, if you are deploying this setup outside of university accommodation, you can skip this step.

OS Installation

  1. Flash the latest version of Ubuntu Server onto a microSD card using Raspberry Pi Imager. Add the following customization options:
    • Hostname: pi5 (or another hostname)
    • Username: mish (or another username) and a password of your choice
    • Set time zone and keyboard layout
    • Enable SSH with public-key authentication only
  2. Insert the microSD card into the Pi, connect power and network cables
  3. SSH into the Pi to perform the rest of the setup

Update packages

sudo apt update
sudo apt upgrade

More than likely, apt will prompt you to reboot:

sudo reboot

Install useful packages

sudo apt install micro btop fastfetch lazygit

Install nice-to-have packages

sudo apt install iperf3

Allow iperf3 to start as a daemon because why not.

You can also perform a bandwidth test using iperf3 -c.

Shell configuration

Fix coloured prompt with Kitty

I use Kitty as my terminal, and by default Ubuntu Server doesn’t want to give a coloured prompt to Kitty. To fix this, uncomment the following line in ~/.bashrc:

force_color_prompt=yes

Set up Bash aliases for Docker Compose

Create ~/.bash_aliases:

alias dc='sudo docker compose'
alias up='sudo docker compose up -d'
alias upl='sudo docker compose up -d && sudo docker compose logs --follow'
alias dcp='sudo docker compose pull && sudo docker compose up -d'
alias aptu='sudo apt update && sudo apt upgrade'

Set up Tailscale

Install Tailscale

See https://tailscale.com/download/linux/ for instructions.

Connect to the tailnet

Connect the Pi to the mmk21hub.github tailnet (use Github OAuth to sign in to Tailscale).

sudo tailscale up

Check that the host has appeared on the Tailscale dashboard. Then,

  1. Disable key expiry for the device
  2. Set its IPv4 address to something memorable like 100.64.2.10 (the 2 represents it being at uni, and the 10 is because I use multiples of 10 for Pis)

Install UniFi OS Server

Follow the Linux instructions at Self-Hosting UniFi - help.ui.com

Set up Docker Compose services

Install Docker

See https://docs.docker.com/engine/install/ubuntu/.

Set up a SSH key for Git clones (optional)

Required if you want to push Docker Compose config changes back GitHub.

ssh-keygen -t ed25519 -C "mish@tau"

Then add the public key to your GitHub account.

You can optionally give it a custom file name (-f), but then you’ll need to add an entry for github.com to your ~/.ssh/config.

Pull Docker Compose configs

Git clone the RPi 5 Docker config repo!

git clone -v [email protected]:MMK21Hub/pi5-docker.git docker

Then bring everything up in probably whatever order you like. You can use the upl alias to bring the service up and watch its logs once it starts.

Docker Compose secrets

Some services use Docker secrets for secrets. Some of them can just be generated, e.g.

  • openssl rand -base64 32 > librespeed/password.secret

Others may be optional, or perhaps API keys that you will need to source.

Secrets are currently not centrally documented, but I try to document them with comments in the Compose files.