Hosting Lemmy on a Pi

I recommend doing this locally on your pc if possible, before moving to a pi or other more complex setup.

Because of the current setup of lemmy software it cannot compile from scratch (install directly) on a raspberry pi. This means we have to use a prebuilt version of lemmy. The easiest way to do this is to use another software called docker to download it into an environment and use it alongside postgres (text) and pictrs (image) as its databases.

If you are wondering what docker is, it enables us to create complex server configurations easily through one or two configuration files. Think of configuration files as option menus but just in a file.

Install Docker on Pi + elsewhere

Edited from HERE

Firstly we need to install docker so that we can then install lemmy!

To do that we will use the convenience script from get.docker.com as it makes it quite easy.

Download the Docker install script

To download the convenience script you just need to run the following command:

curl -fsSL https://get.docker.com -o get-docker.sh

Run the Docker install script

Execute the installation script:

sudo sh get-docker.sh

Add your user to the Docker group (Optional)

If you would like to use Docker as a non-root user and not have to type sudo each time, you have to add your user to the “docker” group with something like:

sudo usermod -aG docker ${USER}

NOTE: you will need to restart or logout and back in for this change to take effect.

Test the install

Lets test it with a basic docker hello world test image:

sudo docker run hello-world

It should print out "hello world" in the middle of some other bits.

Install Lemmy with Docker

Heavily edited from Lemmy's install instructions

Now we are going to install lemmy with docker on our system. To do that we are going to pull their templates configs and modify them to our needs. After it is ready we can then install and visit our docker setup.

Download template files

To install go to THIS GITHUB REPO and if there is a newer version/branch feel free to try this instead, but at the moment it works for 0.19.0. This also doesn't ultimately define the version we use, but is a working template of configurations that we are going to edit from.

We are going to use wget to download the raw files from github. If you don't have wget do:

sudo apt-get install wget

Then we use wget to download the 0.19.0 templates:

wget https://raw.githubusercontent.com/LemmyNet/lemmy/0.19.0/docker/docker-compose.yml
wget https://raw.githubusercontent.com/LemmyNet/lemmy/0.19.0/docker/lemmy.hjson
wget https://raw.githubusercontent.com/LemmyNet/lemmy/0.19.0/docker/nginx.conf

Optional: f you'd like to learn more about the customization, have a look at the config file named lemmy.hjson, and adjust it accordingly, as this is a very basic setup.

Lemmy docker image for pi / arm

check out this repo by ubergeek, for a multi-arch docker image.

swap the image: of lemmy and lemmy-ui to one of ubergeeks.

Database tweaks

To optimize your database, add this file.

You can input your system specs, using this tool: https://pgtune.leopard.in.ua/

wget https://raw.githubusercontent.com/LemmyNet/lemmy-ansible/main/examples/customPostgresql.conf`

Folder permissions

Set the correct permissions for pictrs folder:

mkdir -p volumes/pictrs
sudo chown -R 991:991 volumes/pictrs

Run:

docker compose up -d

lemmy-ui is accessible on the server at http://localhost:{{ lemmy_port }}