Synology lemmy scaled Synology lemmy scaled Tutorial: Lemmy on Synology with Docker
Published August 18, 2023. Edited October 02, 2023

Like many others, I found myself a little frustrated with Reddit essentially killing off 3rd party access to its APIs and arguably mistreating a number of volunteer moderators and communities in the process. This left me with a social-media/bored-scrolling hole that Lemmy has since filled. The Fediverse feels a lot like what the internet did 15 years ago, but with that, it also means that changes to one instance of Lemmy can wildly change the experience for users. Instead of worrying about an instance federating and defederating from other instances, why not just host your own instance?

I happen to have a Synology NAS running anyway, so I decided to try throwing Lemmy on it using Synology's Container Manager. Unfortunately, Lemmy's docs for installing with Docker leave a lot to be desired. In fact, they flat-out didn't work without some modifications. I'll try to fill in those gaps with this tutorial, using mostly the default setup configuration where we can.

Note 1: These instructions reference files on the main branch at the time of posting, so it's possible some references may have changed by the time anyone reads this.

Note 2: This tutorial expects that you've already purchased and set up a domain and have traffic already being forwarded to your Synology NAS through your home router. If you need help with either of these steps, send me a message.

1. Create the project directories

If you've used Container Manager before with your Synology NAS, you probably already have a docker directory with some project directories under it somewhere in its file system. We first need to create the following directory map underneath it for our Lemmy containers:

`-- docker
    `-- lemmy
        `-- volumes
            |-- lemmy-ui
            |    `-- extra_themes
            |-- pictrs
            `-- postgres

It should look like this in Synology's File Station:

2. Add some necessary files

Although the docs imply some of these files are optional, they appear to all be required and most require some editing for Lemmy to work.

2a. Add docker-compose file

Download the file from GitHub and save it as docker-compose.yml.

Edit the file and replace any instances of {{ }} in the file with the following:

  • {{ lemmy_port }} -> 1236 (default port chosen by the Lemmy devs)
  • {{ lemmy_docker_image }} -> dessalines/lemmy:0.18.4 (Select whichever version you'd like to run from https://hub.docker.com/r/dessalines/lemmy/tags)
  • {{ lemmy_docker_ui_image }} -> dessalines/lemmy-ui:0.18.4 (Select whichever version you'd like to run from https://hub.docker.com/r/dessalines/lemmy-ui/tags)
  • {{ domain }} -> your-domain.tld (Pick whatever domain you've set up through your registrar for this purpose)
  • {{ postgres_password }} -> <your-password> (Pick a password that will be used for the Lemmy DB)

Finally, upload it to the top lemmy directory.

2b. Add lemmy config file

Download the file from GitHub and save it as lemmy.hjson.

Edit the file and replace any instances of {{ }} in the file with the following:

  • {{ domain }} -> your-domain.tld (Use the same value you used in the docker-compose.yml file)
  • {{ postgres_password }} -> <your-password> (Use the same value you used in the docker-compose.yml file)

Now upload it to the top lemmy directory.

2c. Add nginx config file

Download the file from GitHub and save it as nginx_internal.conf.

There's no need to edit this file. Just uplaod it to the top lemmy directory

2d. Add postgres config file

Download the file from GitHub and save it as customPostgresql.conf.

I didn't bother to make any changes to this file as well, but I'll reevaluate as time goes on depending on how performance goes. Upload it to the top lemmy directory as well.

2e. Sanity check

At this point, your lemmy directory should look something like this:

3. Set up SSL certificate with LetsEncrypt

This step is optional but recommended unless you want to use an unencrypted connection for some reason. I'm leaving this section mostly blank as my setup is likely different from yours as I'm actually using a second reverse proxy in front of the reverse proxy in this project that handles the SSL layer.

If you're forwarding traffic directly to your Synology NAS from your router, you can set up a certificate through Synology using [these instructions]((https://kb.synology.com/en-my/DSM/tutorial/How_to_enable_HTTPS_and_create_a_certificate_signing_request_on_your_Synology_NAS).

You'll then need to add the relevant ssl configurations to the nginx config file above. You can follow the Lemmy docs for this part.

4. Create the Project

Open Container Manager in Synology OS and click "Create":

Name your project as "lemmy". Then click "Set path" and navigate to your "lemmy" directory that we used above. You'll see a dialog like the one below since we already have our docker-compose.yml file:

Click OK. Your should now see the docker-compose.yml contents from above with your edits:

Click "Next" and you'll see a Web Portal settings page with a checkbox. If you haven't installed Web Station yet, you'll be prompted by the following dialog:

Go ahead and install Web Station and then set up the web portal with the following options:

Click "Next" and then "Done" on the following screen:

Upon clicking "Done", you'll see the images start to download and the containers start to be built. This will take a couple minutes, but there should also be a prompt to go configure the web portal:

Click "OK" and create a port-based web portal with HTTP port checked and set to 8536. Then click "Create":

Now go back to Container Manager and verify that the build has completed with Exit Code: 0.

That's it. Your lemmy instance should now be running and you should be able to type the domain you're using in your browser and see the Lemmy Instance Setup page:

From here, create your admin account and configure your Lemmy instance however you'd like. Now you're part of the Fediverse!

lemmy
synology
docker