Skip to content

Instantly share code, notes, and snippets.

@bdeshi
Created April 24, 2022 12:19
Show Gist options
  • Save bdeshi/08c61b9685585773bbe5f3db3692502c to your computer and use it in GitHub Desktop.
Save bdeshi/08c61b9685585773bbe5f3db3692502c to your computer and use it in GitHub Desktop.
lemmy caprover oneclick app
captainVersion: 4
services:
$$cap_appname-db:
image: postgres:12-alpine
environment:
POSTGRES_USER: $$cap_db_username
POSTGRES_PASSWORD: $$cap_db_password
POSTGRES_DB: $$cap_db_database
volumes:
- $$cap_appname-db-data:/var/lib/postgresql/data
restart: always
caproverExtra:
notExposeAsWebApp: 'true'
$$cap_appname-backend:
image: dessalines/lemmy:0.16.2
ports:
- "$$cap_backend_port:8536"
- "6669:6669"
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_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"
LEMMY_DATABASE_URL: "postgres://$$cap_db_username:$$cap_db_password@srv-captain--$$cap_appname-db:5432/$$cap_db_database"
volumes:
- $$cap_appname-backend-config:/config/
depends_on:
- $$cap_appname-db
- $$cap_appname-pictrs
caproverExtra:
notExposeAsWebApp: 'true'
$$cap_appname:
image: dessalines/lemmy-ui:0.16.2
# ports:
# - "127.0.0.1:1235:1234"
restart: always
environment:
LEMMY_INTERNAL_HOST: srv-captain--$$cap_appname-backend:8536
LEMMY_EXTERNAL_HOST: $$cap_appname.$$cap_root_domain:$$cap_backend_port
LEMMY_HTTPS: true
depends_on:
- $$cap_appname-backend
caproverExtra:
containerHttpPort: "1234"
$$cap_appname-pictrs:
# image: asonix/pictrs:0.3.1
ports:
- "$$cap_pictrs_port:8080"
# - "127.0.0.1:6670:6669"
volumes:
- $$cap_appname-pictrs-mnt:/mnt
restart: always
caproverExtra:
notExposeAsWebApp: 'true'
dockerfileLines:
- FROM asonix/pictrs:0.3.1
- USER 991:991
caproverOneClickApp:
variables:
- id: $$cap_db_username
label: Database user
defaultValue: lemmy
validRegex: /^[a-zA-Z0-9_]{1,32}$/
- id: $$cap_db_password
label: Database password
validRegex: /.{1,}/
- id: $$cap_db_database
label: Database name
defaultValue: lemmy
validRegex: /^[a-zA-Z0-9_]{1,32}$/
- id: $$cap_backend_port
label: lemmy backend service port
description: port where lemmy core will be available
defaultValue: 8536
validRegex: /^[1-9][0-9]{3,4}$/
- id: $$cap_pictrs_port
label: pictrs service port
description: port where pictrs will be available
defaultValue: 8537
validRegex: /^[1-9][0-9]{3,4}$/
instructions:
start: >-
Lemmy is a link aggregator / Reddit clone for the fediverse.
Enter the configuration parameters and click next. A postgres Database and Lemmy component containers will be created. The process should take less than infinity to finish.
end: >-
Lemmy is deployed and available as $$cap_appname, $$cap_appname-backend, $$cap_appname-pictrs, and $$cap_appname-db.
IMPORTANT: It might take awhile for Lemmy to get ready. Meanwhile you might may see a 5xx error. This is probably normal. If you are getting mysterious errors, check logs of $$cap_appname-backend, $$cap_appname-pictrs, and $$cap_appname.
These ports are public: $$cap_backend_port, 6669, $$cap_pictrs_port
displayname: Lemmy
isOfficial: true
description: >-
Lemmy is similar to sites like Reddit, Lobste.rs, or Hacker News: you subscribe to forums you're interested in, post links and discussions, then vote, and comment on them.
Behind the scenes, it is very different; anyone can easily run a server, and all these servers are federated (think email), and connected to the same universe, called the Fediverse.
documentation: Based on https://github.com/LemmyNet/lemmy/blob/main/docker/prod/docker-compose.yml.
# this is for Caprover > Lemmy > HTTP Settings > Default Nginx Configuration
# adjust hostname & port for lemmy backend according to oneclick app values.
<% if (s.forceSsl) { %>
server {
listen 80;
server_name <%-s.publicDomain%>;
# Used by Lets Encrypt
location /.well-known/acme-challenge/ {
root <%-s.staticWebRoot%>;
}
# Used by CapRover for health check
location /.well-known/captain-identifier {
root <%-s.staticWebRoot%>;
}
location / {
return 302 https://$http_host$request_uri;
}
}
<% } %>
server {
<% if (!s.forceSsl) { %>
listen 80;
<% } %>
<% if (s.hasSsl) { %>
listen 443 ssl http2;
ssl_certificate <%-s.crtPath%>;
ssl_certificate_key <%-s.keyPath%>;
<% } %>
server_name <%-s.publicDomain%>;
# 127.0.0.11 is DNS set up by Docker, see:
# https://docs.docker.com/engine/userguide/networking/configure-dns/
# https://github.com/moby/moby/issues/20026
resolver 127.0.0.11 valid=10s;
client_max_body_size 500m;
# IMPORTANT!! If you are here from an old thread to set a custom port, you do not need to modify this port manually here!!
# Simply change the Container HTTP Port from the dashboard HTTP panel
set $upstream http://<%-s.localDomain%>:<%-s.containerHttpPort%>;
# Used by Lets Encrypt
location /.well-known/acme-challenge/ {
root <%-s.staticWebRoot%>;
}
# Used by CapRover for health check
location /.well-known/captain-identifier {
root <%-s.staticWebRoot%>;
}
error_page 502 /captain_502_custom_error_page.html;
location = /captain_502_custom_error_page.html {
root <%-s.customErrorPagesDirectory%>;
internal;
}
# The default ports:
# lemmy_ui_port: 1235
# lemmy_port: 8536
# lemmy frontend
location / {
<% if (s.httpBasicAuthPath) { %>
auth_basic "Restricted Access";
auth_basic_user_file <%-s.httpBasicAuthPath%>;
<% } %>
set $proxy_target $upstream;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
<% if (s.websocketSupport) { %>
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_http_version 1.1;
<% } %>
if ($http_accept ~ "^application/.*$") {
set $proxy_target "http://srv-captain--lemmy-backend:8536";
}
if ($request_method = POST) {
set $proxy_target "http://srv-captain--lemmy-backend:8536";
}
proxy_pass $proxy_target;
}
# lemmy backend
location ~ ^/(api|pictrs|feeds|nodeinfo|.well-known) {
proxy_pass http://srv-captain--lemmy-backend:8536;
<% if (s.websocketSupport) { %>
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_http_version 1.1;
<% } %>
# Rate limit
# limit_req zone={{domain}}_ratelimit burst=30 nodelay;
# Add IP forwarding headers
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
# Redirect pictshare images to pictrs
location ~ /pictshare/(.*)$ {
return 301 /pictrs/image/$1;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment