From 12683c84edf0536bb5ba8ceca7f7e16b6cb768dd Mon Sep 17 00:00:00 2001 From: Alexey Kovrizhkin Date: Sat, 20 Jan 2024 23:34:17 +0300 Subject: [PATCH] ready to test --- .gitignore | 3 +- Makefile | 94 ++++++++++++++++++++++++++++++++++++++-------- README.md | 18 ++++----- docker-compose.yml | 76 ++++++++++++++++++++++++++++++++++--- 4 files changed, 160 insertions(+), 31 deletions(-) diff --git a/.gitignore b/.gitignore index e6905a2..c909762 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ -.env* \ No newline at end of file +.env* +lemmy.hjson diff --git a/Makefile b/Makefile index 880c8f8..3cf5194 100644 --- a/Makefile +++ b/Makefile @@ -7,19 +7,39 @@ CFG ?= .env CFG_BAK ?= $(CFG).bak #- App name -APP_NAME ?= service-template +APP_NAME ?= lemmy #- Docker image name -IMAGE ?= ghcr.io/lekovr/service-template +IMAGE ?= dessalines/lemmy-ui #- Docker image tag -IMAGE_VER ?= 0.1.0 - -# If you need database, uncomment this var -#USE_DB = yes - -# If you need user name and password, uncomment this var -#ADD_USER = yes +IMAGE_VER ?= 0.19.2 + +#- lemmy docker image +LEMMY_IMAGE ?= dessalines/lemmy +#- lemmy docker image tag +LEMMY_IMAGE_VER ?= $(IMAGE_VER) + +#- pict-rs docker image +PICTRS_IMAGE ?= docker.io/asonix/pictrs +#- pict-rs docker image tag +PICTRS_IMAGE_VER ?= 0.4.7 +#- pict-rs API key +PICTRS_API_KEY ?= $(shell < /dev/urandom tr -dc A-Za-z0-9 | head -c14; echo) + +#- Hostname and port of the smtp server +SMTP_SERVER ?= +#- Login name for smtp server +SMTP_USER ?= +#- Password to login to the smtp server +SMTP_PASS ?= +#- Address to send emails from, eg "noreply@your-instance.com" +SMTP_FROM ?= +#- Whether or not smtp connections should use tls. Can be none, tls, or starttls +SMTP_TLS_TYPE ?= none + +USE_DB = yes +ADD_USER = yes # ------------------------------------------------------------------------------ @@ -31,12 +51,42 @@ export export # This content will be added to .env -# define CONFIG_CUSTOM -# # ------------------------------------------------------------------------------ -# # Sample config for .env -# #SOME_VAR=value -# -# endef +define CONFIG_HJSON + # Settings related to activitypub federation + # Pictrs image server configuration. + pictrs: { + # Address where pictrs is available (for image hosting) + url: "http://pictrs:8080/" + # Set a custom pictrs API key. ( Required for deleting images ) + api_key: "$(PICTRS_API_KEY)" + } + # Email sending configuration. All options except login/password are mandatory + email: { + # Hostname and port of the smtp server + smtp_server: "$(SMTP_SERVER)" + # Login name for smtp server + smtp_login: "$(SMTP_USER)" + # Password to login to the smtp server + smtp_password: "$(SMTP_PASS)" + # Address to send emails from, eg "noreply@your-instance.com" + smtp_from_address: "$(SMTP_FROM)" + # Whether or not smtp connections should use tls. Can be none, tls, or starttls + tls_type: "$(SMTP_TLS)" + } + # Parameters for automatic configuration of new instance (only used at first start) + setup: { + # Username for the admin user + admin_username: "$(USER_NAME)" + # Password for the admin user. It must be at least 10 characters. + admin_password: "$(USER_PASS)" + # Name of the site (can be changed later) + site_name: "My Lemmy Instance" + # Email for the admin user (optional, can be omitted and set later through the website) + admin_email: "$(USER_EMAIL)" + } + # the domain name of your instance (mandatory) + hostname: "$(APP_SITE)" +endef # ------------------------------------------------------------------------------ # Find and include DCAPE_ROOT/Makefile @@ -56,5 +106,17 @@ use-template: .default-deploy: prep -prep: +prep: lemmy.hjson @echo "Just to show we able to attach" + mkdir -p volumes/pictrs + sudo chown -R 991:991 volumes/pictrs + +lemmy.hjson: + @echo "$$CONFIG_HJSON" > $@ + + +getconfig: + wget https://raw.githubusercontent.com/LemmyNet/lemmy-ansible/main/templates/docker-compose.yml + wget https://raw.githubusercontent.com/LemmyNet/lemmy-ansible/main/examples/config.hjson -O lemmy.hjson + wget https://raw.githubusercontent.com/LemmyNet/lemmy-ansible/main/templates/nginx_internal.conf + wget https://raw.githubusercontent.com/LemmyNet/lemmy-ansible/main/files/proxy_params diff --git a/README.md b/README.md index 4ec2c74..cbbe0be 100644 --- a/README.md +++ b/README.md @@ -1,19 +1,19 @@ -# dcape-app-template +# dcape-app-lemmy [![GitHub Release][1]][2] [![GitHub code size in bytes][3]]() [![GitHub license][4]][5] -[1]: https://img.shields.io/github/release/dopos/dcape-app-template.svg -[2]: https://github.com/dopos/dcape-app-template/releases -[3]: https://img.shields.io/github/languages/code-size/dopos/dcape-app-template.svg -[4]: https://img.shields.io/github/license/dopos/dcape-app-template.svg +[1]: https://img.shields.io/github/release/dopos/dcape-app-lemmy.svg +[2]: https://github.com/dopos/dcape-app-lemmy/releases +[3]: https://img.shields.io/github/languages/code-size/dopos/dcape-app-lemmy.svg +[4]: https://img.shields.io/github/license/dopos/dcape-app-lemmy.svg [5]: LICENSE -[upstream_name](https://upstream_url) application package for [dcape](https://github.com/dopos/dcape). +[lemmy](https://join-lemmy.org/) application package for [dcape](https://github.com/dopos/dcape). ## Upstream * Project: [upstream_name](https://upstream_url) -* Docker: [template](https://hub.docker.com/r/template) +* Docker: [lemmy](https://hub.docker.com/r/dessalines/lemmy), [lemmy-ui](https://hub.docker.com/r/dessalines/lemmy-ui) ## Requirements @@ -38,8 +38,8 @@ Run commands on deploy host with [dcape](https://github.com/dopos/dcape) installed: ```bash -git clone https://github.com/dopos/dcape-app-template.git -cd dcape-app-template +git clone https://github.com/dopos/dcape-app-lemmy.git +cd dcape-app-lemmy make config-if ... make up diff --git a/docker-compose.yml b/docker-compose.yml index 58e9797..2a2e8e6 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,9 +1,75 @@ -# This file will be joined with docker-compose.app.yml from dcape -# See https://github.com/dopos/dcape +version: "3.7" + +x-logging: &default-logging + driver: "json-file" + options: + max-size: "50m" + max-file: "4" services: - # This service will extend code from dcape app: environment: - # Some var to keep YML struct - - DEBUG=yes + - LEMMY_UI_LEMMY_EXTERNAL_HOST=${APP_SITE} + - LEMMY_UI_LEMMY_INTERNAL_HOST=lemmy:8536 + - LEMMY_HTTPS=true + volumes: + - ./volumes/lemmy-ui/extra_themes:/app/extra_themes + labels: + - traefik.http.services.${APP_TAG}.loadbalancer.server.port=1234 + depends_on: + - lemmy + restart: always + logging: *default-logging + + lemmy: + image: ${LEMMY_IMAGE}:${LEMMY_IMAGE_VER} + hostname: lemmy + restart: always + logging: *default-logging + environment: + - LEMMY_DATABASE_URL=postgres://${PGUSER}:${PGPASSWORD}@db/${PGDATABASE}?sslmode=disable +# - LEMMY_SMTP_PASSWORD=${SMTP_PASSWORD} + - RUST_BACKTRACE=1 + labels: + - traefik.enable=true + - dcape.traefik.tag=${DCAPE_TAG} + - traefik.http.routers.${APP_TAG}_srv.tls=${USE_TLS} + - traefik.http.routers.${APP_TAG}_srv.tls.certresolver=default + # code from https://github.com/LemmyNet/lemmy/pull/3502/files + - traefik.http.routers.${APP_TAG}_srv.rule=Host(`${APP_SITE}`) && (PathPrefix(`/api`) || PathPrefix(`/pictrs`) || PathPrefix(`/feeds`) || PathPrefix(`/nodeinfo`) || PathPrefix(`/.well-known`) || Method(`POST`) || HeadersRegexp(`Accept`, `^[Aa]pplication/.*`)) + # Docker stack doesn't provide port information to traefik, so we need to set it manually + - traefik.http.services.${APP_TAG}_srv.loadbalancer.server.port=8536 + volumes: + - /etc/timezone:/etc/timezone:ro + - /etc/localtime:/etc/localtime:ro + - /etc/ssl/certs:/etc/ssl/certs:ro + - ./lemmy.hjson:/config/config.hjson:Z + depends_on: + - pictrs + + pictrs: + image: ${PICTRS_IMAGE}:${PICTRS_IMAGE_VER} + # this needs to match the pictrs url in lemmy.hjson + hostname: pictrs + # 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 + environment: + #- PICTRS_OPENTELEMETRY_URL=http://otel:4137 + - PICTRS__API_KEY=${PICTRS_API_KEY} + - RUST_LOG=debug + - RUST_BACKTRACE=full + - PICTRS__MEDIA__VIDEO_CODEC=vp9 + - PICTRS__MEDIA__GIF__MAX_WIDTH=256 + - PICTRS__MEDIA__GIF__MAX_HEIGHT=256 + - PICTRS__MEDIA__GIF__MAX_AREA=65536 + - PICTRS__MEDIA__GIF__MAX_FRAME_COUNT=400 + user: 991:991 + volumes: + - ./volumes/pictrs:/mnt:Z + restart: always + logging: *default-logging + deploy: + resources: + limits: + memory: 690m +