https://github.com/ubergeek77/Lemmy-Easy-Deploy
git clone https://github.com/LemmyNet/lemmy.git cd lemmy/docker docker-compose up -d
Docker compose
version: '2' services: nginx_lemmy: image: nginx:mainline-alpine restart: always ports: # - <yourReverseProxyTargetPort>:80 - 80:80 depends_on: - lemmy volumes: - ./nginx.conf:/etc/nginx/nginx.conf:ro lemmy: # Update this tag name when the software updates image: dessalines/lemmy:0.17.4 restart: always environment: - RUST_LOG="warn,lemmy_server=info,lemmy_api=info,lemmy_api_common=info,lemmy_api_crud=info,lemmy_apub=info,lemmy_db_queries=info,lemmy_db_schema=info,lemmy_db_views=info,lemmy_db_views_actor=info,lemmy_db_views_moderator=info,lemmy_routes=info,lemmy_utils=info,lemmy_websocket=info" volumes: - ./lemmy.hjson:/config/config.hjson depends_on: - postgres - pictrs lemmy-ui: # Update this tag name when the software updates image: dessalines/lemmy-ui:0.17.4 restart: always environment: - LEMMY_UI_LEMMY_INTERNAL_HOST=lemmy:8536 - LEMMY_UI_LEMMY_EXTERNAL_HOST=lemmy - LEMMY_UI_HTTPS=true volumes: - ./volumes/lemmy-ui/extra_themes:/app/extra_themes depends_on: - lemmy postgres: image: postgres:15-alpine environment: - POSTGRES_USER=lemmy - POSTGRES_PASSWORD=PUT_IN_A_GOOD_PASSWORD_HERE!!! - POSTGRES_DB=lemmy volumes: - ./volumes/postgres:/var/lib/postgresql/data # - ./customPostgresql.conf:/etc/postgresql.conf restart: always pictrs: image: asonix/pictrs:latest user: 991:991 volumes: - ./volumes/pictrs:/mnt restart: always mem_limit: 200m # we can set options to pictrs like this, here we set max. image size and forced format for conversion # entrypoint: /sbin/tini -- /usr/local/bin/pict-rs -p /mnt -m 4 --image-format webp # Not needed if you are using gmail #postfix: # image: mwader/postfix-relay # environment: # # Your domain name without any protocol or slashes. e.g. lemmy.yourdomain.net # - POSTFIX_myhostname=lemmy.yourdomain.net # restart: always
lemmy.hjson
{
# for more info about the config, check out the documentation
# https://join-lemmy.org/docs/en/administration/configuration.html
# only few config options are covered in this example config
setup: {
# username for the admin user
admin_username: "yourAdminName"
# password for the admin user
# remove this password after your account is created, imo.
admin_password: "yourAdminPassword"
# name of the site (can be changed later)
site_name: "A selfhosted place"
}
# the domain name of your instance (eg "lemmy.ml")
hostname: "lemmy.yourdomain.net"
# address where lemmy should listen for incoming requests
bind: "0.0.0.0"
# port where lemmy should listen for incoming requests
port: 8536
# Whether the site is available over TLS. Needs to be true for federation to work.
tls_enabled: true
# pictrs host
pictrs: {
url: "http://pictrs:8080/"
# api_key: "API_KEY"
}
# settings related to the postgresql database
database: {
# name of the postgres database for lemmy
database: "lemmy"
# username to connect to postgres
user: "lemmy"
# password to connect to postgres
password: "PUT_IN_A_GOOD_PASSWORD_HERE!!!"
# host where postgres is running
host: "postgres"
# port where postgres can be accessed
port: 5432
# maximum number of active sql connections
pool_size: 5
}
email: {
# Hostname and port of the smtp server
smtp_server: "smtp.gmail.com:587"
# Login name for smtp server
smtp_login: "yourEmail@gmail.com"
# Password to login to the smtp server
smtp_password: "yourAppPassword"
# Address to send emails from, eg "noreply@your-instance.com"
smtp_from_address: "yourEmail@gmail.com"
# Whether or not smtp connections should use tls. Can be none, tls, or starttls
tls_type: "starttls"
}
}
nginx.conf
worker_processes 1;
events {
worker_connections 1024;
}
http {
upstream lemmy {
# this needs to map to the lemmy (server) docker service hostname
server "lemmy:8536";
}
upstream lemmy-ui {
# this needs to map to the lemmy-ui docker service hostname
server "lemmy-ui:1234";
}
server {
# this is the port inside docker, not the public one yet
listen 80;
# listen 8536;
# change if needed, this is facing the public web
server_name localhost;
server_tokens off;
gzip on;
gzip_types text/css application/javascript image/svg+xml;
gzip_vary on;
# Upload limit, relevant for pictrs
client_max_body_size 20M;
add_header X-Frame-Options SAMEORIGIN;
add_header X-Content-Type-Options nosniff;
add_header X-XSS-Protection "1; mode=block";
# frontend general requests
location / {
# distinguish between ui requests and backend
# don't change lemmy-ui or lemmy here, they refer to the upstream definitions on top
set $proxpass "http://lemmy-ui";
if ($http_accept = "application/activity+json") {
set $proxpass "http://lemmy";
}
if ($http_accept = "application/ld+json; profile=\"https://www.w3.org/ns/activitystreams\"") {
set $proxpass "http://lemmy";
}
if ($request_method = POST) {
set $proxpass "http://lemmy";
}
proxy_pass $proxpass;
rewrite ^(.+)/+$ $1 permanent;
# Send actual client IP upstream
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
# backend
location ~ ^/(api|pictrs|feeds|nodeinfo|.well-known) {
proxy_pass "http://lemmy";
# proxy common stuff
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
# Send actual client IP upstream
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
}