I have to admit, I haven’t posted much this year. As I just posted a simple solution for problems I encountered during my development in Go (see this), and I feel this is not enough.
I decided to document my process of setting up my own Lemmy instance o0o Community (Still setting up the rules and stuff for the instance) using Docker, since I have a lot of issues with the official documentation.
I feel like this guide will simplify things a bit for you to stop you from jumping around different places of documentation, but, well, it is still not that simple to set up Lemmy. Hope you find this shitty guide useful.
First things first
The very first thing of self-hosting Lemmy is following the official documentation. To save you time from jumping around, I will include the part here:
Make sure docker and docker compose 2.0 is installed;
We are not downloading the docker-compose.yml and lemmy.hjson from the repository; I will show you how to set up them in the next part.
For customPostgresql.conf, I would suggest you directly generate the file from https://pgtune.leopard.in.ua/ and include the following at the end:
1 2 3 4 5
# Other custom params synchronous_commit=off
# Listen beyond localhost listen_addresses = '*'
Make sure the listen_addresses line is included, otherwise, you won’t be able to start the server, and it will complain you cannot connect to Postgresql.
And we are completed for now. We will go back to the official documentation later, because for docker-compose.yml and lemmy.hjson, I modified and simplified for you.
However, since there are a lot of fields not needed for a simple setup (of course, if you want a more complete setup, you can totally just follow the default file in the above link):
{ # Settings related to the Postgresql database database: { # Username to connect to postgres user: "string" # Password to connect to postgres password: "string" # Host where postgres is running host: "string" # Port where postgres can be accessed port: 5432 # Name of the postgres database for lemmy database: "string" # Maximum number of active sql connections pool_size: 95 } # Settings related to activitypub federation # Pictrs image server configuration. pictrs: { # Address where pictrs is available (for image hosting) url: "http://localhost:8080/" # Set a custom pictrs API key. ( Required for deleting images ) api_key: "string" # Cache remote images cache_remote_images: true } # Email sending configuration. All options except login/password are mandatory email: { # Hostname and port of the smtp server smtp_server: "localhost:25" # Login name for smtp server smtp_login: "string" # Password to login to the smtp server smtp_password: "string" # Address to send emails from, eg "noreply@your-instance.com" smtp_from_address: "noreply@example.com" # Whether or not smtp connections should use tls. Can be none, tls, or starttls tls_type: "none" } # Parameters for automatic configuration of new instance (only used at first start) setup: { # Username for the admin user admin_username: "admin" # Password for the admin user. It must be between 10 and 60 characters. admin_password: "" # Name of the site, can be changed later. Maximum 20 characters. site_name: "My Lemmy Instance" # Email for the admin user (optional, can be omitted and set later through the website) admin_email: "user@example.com" } # the domain name of your instance (mandatory) hostname: "<YOUR_DOMAIN>" }
Also, we will need postgresql database info and pictrs API key later in the next step when we change the docker-compose.yml just to keep in mind.
docker-compose.yml
For this section, the downloaded file is a template file designed for Ansible; which we need to have a lot of editing to make the work. So to save time, here is a completed version for you:
LEMMY_VERSION=0.18.5 DOMAIN= # postgres POSTGRES_USER= POSTGRES_PASSWORD= POSTGRES_DB= # pictrs ## keys PICTRS_API_KEY= ### 15 random characters PICTRS_SAFETY_WORKER_AUTH= ### 80 random characters PICTRS_SECRET_KEY= ## storage type; by default is filesystem for object storage please set it to object_storage PICTRS_STORE_TYPE=filesystem PICTRS_STORE_ENDPOINT= PICTRS_STORE_BUCKET_NAME= PICTRS_STORE_REGION= PICTRS_STORE_USE_PATH_STYLE=false PICTRS_STORE_ACCESS_KEY= PICTRS_STORE_SECRET_KEY=
Most of them are very self-explanatory but I will need to talk about pictrs a bit; if you want to do further customizations, the full pictrs documentation is located here: https://git.asonix.dog/asonix/pict-rs/src/branch/main/pict-rs.toml, somehow is not easy to find via search engines.
Annnnd start!
afterward, the core files should now be properly prepared. We should now go back to the official documentation with the step Folder permissions to start the server; Again, I will post the step directly here:
And finally, docker compose up -d to start the server.
You can also optionally follow the step Reverse Proxy / Webserver and Let’s Encrypt if you need. And afterwards, you will get a working Lemmy server using Docker.