Raspberry Pi Setup

Below are the steps I take to setup a new Raspberry Pi. Many of these steps I use to setup Linux machines in general.

Headless Setup

First thing I do after using Etcher to burn the image to the SD card is setup wpa_supplicant.conf

country=us
update_config=1
ctrl_interface=/var/run/wpa_supplicant

network={
    scan_ssid=1
    ssid="network_name"
    psk="Sup3rSecr3tP4ssw0rd"
}

Also create an empty file called ssh
These files go on the boot volume of the SD card.

Updates

As always the first thing to do once the system is on the wireless network and you can login is change the password and do updates.

passwd
sudo apt-get update
sudo apt-get upgrade

Install Docker

curl -fsSL https://get.docker.com -o get-docker.sh && sh get-docker.sh
sudo usermod -aG docker $USER

Install Docker Compose

sudo apt-get install docker-compose

Install Packages

sudo apt-get install git zsh build-essential deborphan debian-goodies vim exa 

Install Oh My Zsh

sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"

Install NVM and NodeJS

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh | bash

Add the following to the .zshrc

export NVM_DIR=~/.nvm
 [ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"

Then install NodeJS

nvm install lts/erbium

Install Zsh Plugins

zsh-autosuggestions and zsh-syntax-highlighting

git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting

Then enable the plugins in the .zshrc file plugins=(git docker zsh-autosuggestions zsh-syntax-highlighting)

Setup Zerotier

Running inside a docker container... this docker image is not the official image but it supports many of the architectures I use

docker volume create zerotier
docker run --name zerotier --device=/dev/net/tun --net=host --cap-add=NET_ADMIN --cap-add=SYS_ADMIN -v zerotier:/var/lib/zerotier-one --restart=always -d bltavares/zerotier
docker exec zerotier zerotier-cli join <my private network id>

Docker Compose for Zerotier

version: '3.3'

volumes:
  zerotier:
    driver: local
services:
    zerotier:
        container_name: zerotier
        devices:
            - /dev/net/tun
        network_mode: host
        healthcheck:
          test: ["CMD", "zerotier-cli", "status"]
          interval: 30s
          timeout: 10s
          retries: 5
        cap_add:
            - NET_ADMIN
            - SYS_ADMIN
        volumes:
            - zerotier:/var/lib/zerotier-one
        restart: always
        image: bltavares/zerotier

Install Portainer

docker volume create portainer_data
docker run -d -p 8000:8000 -p 9000:9000 --name=portainer --restart=always -v /var/run/docker.sock:/var/run/docker.sock -v portainer_data:/data portainer/portainer

Enable SelfHostedPro Portainer Templates

  1. Login to your portainer setup go to settings
  2. Enable Use external templates
  3. Add the url: https://raw.githubusercontent.com/SelfhostedPro/selfhosted_templates/master/Template/template.json
  4. Go to app templates and hit refresh at the top

That is it for now. I will update this as I add things to my default setup.