add pleroma

This commit is contained in:
Luna 2022-11-16 23:22:33 -03:00
parent fdddbf8767
commit 2cb4f80e6c
5 changed files with 203 additions and 2 deletions

40
Dockerfile.pleroma Normal file
View file

@ -0,0 +1,40 @@
FROM elixir:1.11.4-alpine
ARG PLEROMA_VER=develop
ARG UID=911
ARG GID=911
ENV MIX_ENV=prod
RUN echo "http://nl.alpinelinux.org/alpine/latest-stable/community" >> /etc/apk/repositories \
&& apk update \
&& apk add git gcc g++ musl-dev make cmake file-dev \
exiftool imagemagick libmagic ncurses postgresql-client ffmpeg
RUN addgroup -g ${GID} pleroma \
&& adduser -h /pleroma -s /bin/false -D -G pleroma -u ${UID} pleroma
ARG DATA=/var/lib/pleroma
RUN mkdir -p /etc/pleroma \
&& chown -R pleroma /etc/pleroma \
&& mkdir -p ${DATA}/uploads \
&& mkdir -p ${DATA}/static \
&& chown -R pleroma ${DATA}
USER pleroma
WORKDIR /pleroma
RUN git clone -b develop https://git.pleroma.social/pleroma/pleroma.git /pleroma \
&& git checkout ${PLEROMA_VER}
RUN echo "import Mix.Config" > config/prod.secret.exs \
&& mix local.hex --force \
&& mix local.rebar --force \
&& mix deps.get --only prod \
&& mkdir release \
&& mix release --path /pleroma
COPY ./files/pleroma.exs /etc/pleroma/config.exs
EXPOSE 4000
ENTRYPOINT ["/pleroma/docker-entrypoint.sh"]

View file

@ -1,10 +1,60 @@
version: "3.9" version: "3.9"
services: services:
#pleroma_db:
# image: postgres:15 pleroma_db:
image: postgres:15
networks:
- pleroma_internal_network
healthcheck:
test: ['CMD', 'pg_isready', '-U', 'postgres']
volumes:
- ./data/pleroma/postgres14:/var/lib/postgresql/data
environment:
- 'POSTGRES_HOST_AUTH_METHOD=trust'
- 'POSTGRES_USER=pleroma'
- 'POSTGRES_PASSWORD=very_secure_pleroma_password'
- 'POSTGRES_DB=pleroma'
#pleroma: #pleroma:
# image: git.pleroma.social:5050/pleroma/pleroma:release-2-4-1 # image: git.pleroma.social:5050/pleroma/pleroma:release-2-4-1
pleroma_web:
image: pleroma_selfbuilt
networks:
- pleroma_internal_network
- pleroma_external_network
healthcheck:
test:
[
"CMD-SHELL",
"wget -q --spider --proxy=off localhost:4000 || exit 1",
]
restart: always
ports:
- '127.0.0.1:20700:4000'
build:
context: .
# Feel free to remove or override this section
# See 'Build-time variables' in README.md
args:
- "UID=1000"
- "GID=1000"
- "PLEROMA_VER=v2.4.2"
volumes:
- ./data/pleroma/uploads:/var/lib/pleroma/uploads
- ./data/pleroma/static:/var/lib/pleroma/static
- ./files/pleroma.exs:/etc/pleroma/config.exs:ro
environment:
DOMAIN: pleroma.pubtester.local
INSTANCE_NAME: Pleroma/pubtester
ADMIN_EMAIL: admin@example.com
NOTIFY_EMAIL: notify@example.com
DB_HOST: pleroma_db
DB_USER: pleroma
DB_PASS: very_secure_pleroma_password
DB_NAME: pleroma
depends_on:
- pleroma_db
# mastodon config # mastodon config
mastodon_db: mastodon_db:
image: postgres:15 image: postgres:15
@ -85,6 +135,8 @@ services:
networks: networks:
- external_network - external_network
- internal_network - internal_network
- pleroma_external_network
- pleroma_internal_network
volumes: volumes:
- ./files/nginx.conf:/etc/nginx/nginx.conf:ro - ./files/nginx.conf:/etc/nginx/nginx.conf:ro
ports: ports:
@ -92,8 +144,12 @@ services:
depends_on: depends_on:
- mastodon_web - mastodon_web
- mastodon_streaming - mastodon_streaming
- pleroma_web
networks: networks:
external_network: external_network:
internal_network: internal_network:
internal: true internal: true
pleroma_external_network:
pleroma_internal_network:
internal: true

View file

@ -63,4 +63,27 @@ http {
tcp_nodelay on; tcp_nodelay on;
} }
} }
server {
listen 80;
listen [::]:80;
root /mnt/none;
index index.html index.htm;
server_name pleroma.pubtester.local;
absolute_redirect off;
server_name_in_redirect off;
error_page 404 /404.html;
error_page 410 /410.html;
location / {
proxy_set_header Host $http_host;
proxy_set_header X-Forwarded-Proto https;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_pass http://pleroma_web:4000;
}
}
} }

71
files/pleroma.exs Normal file
View file

@ -0,0 +1,71 @@
import Config
config :pleroma, Pleroma.Web.Endpoint,
url: [host: System.get_env("DOMAIN", "localhost"), scheme: "http", port: 80],
http: [ip: {0, 0, 0, 0}, port: 4000]
config :pleroma, :instance,
name: System.get_env("INSTANCE_NAME", "Pleroma"),
email: System.get_env("ADMIN_EMAIL"),
notify_email: System.get_env("NOTIFY_EMAIL"),
limit: 5000,
registrations_open: true,
federating: true,
healthcheck: true
config :pleroma, :media_proxy,
enabled: false,
redirect_on_failure: true,
base_url: "https://cache.domain.tld"
config :pleroma, Pleroma.Repo,
adapter: Ecto.Adapters.Postgres,
username: System.get_env("DB_USER", "pleroma"),
password: System.fetch_env!("DB_PASS"),
database: System.get_env("DB_NAME", "pleroma"),
hostname: System.get_env("DB_HOST", "db"),
pool_size: 10
# Configure web push notifications
config :web_push_encryption, :vapid_details, subject: "mailto:#{System.get_env("NOTIFY_EMAIL")}"
config :pleroma, :database, rum_enabled: false
config :pleroma, :instance, static_dir: "/var/lib/pleroma/static"
config :pleroma, Pleroma.Uploaders.Local, uploads: "/var/lib/pleroma/uploads"
# We can't store the secrets in this file, since this is baked into the docker image
if not File.exists?("/var/lib/pleroma/secret.exs") do
secret = :crypto.strong_rand_bytes(64) |> Base.encode64() |> binary_part(0, 64)
signing_salt = :crypto.strong_rand_bytes(8) |> Base.encode64() |> binary_part(0, 8)
{web_push_public_key, web_push_private_key} = :crypto.generate_key(:ecdh, :prime256v1)
secret_file =
EEx.eval_string(
"""
import Config
config :pleroma, Pleroma.Web.Endpoint,
secret_key_base: "<%= secret %>",
signing_salt: "<%= signing_salt %>"
config :web_push_encryption, :vapid_details,
public_key: "<%= web_push_public_key %>",
private_key: "<%= web_push_private_key %>"
""",
secret: secret,
signing_salt: signing_salt,
web_push_public_key: Base.url_encode64(web_push_public_key, padding: false),
web_push_private_key: Base.url_encode64(web_push_private_key, padding: false)
)
File.write("/var/lib/pleroma/secret.exs", secret_file)
end
import_config("/var/lib/pleroma/secret.exs")
# For additional user config
if File.exists?("/var/lib/pleroma/config.exs"),
do: import_config("/var/lib/pleroma/config.exs"),
else:
File.write("/var/lib/pleroma/config.exs", """
import Config
# For additional configuration outside of environmental variables
""")

11
pleroma_setup.sh Executable file
View file

@ -0,0 +1,11 @@
#!/bin/sh
#
# setup pleroma db
docker-compose up -d pleroma_db
docker-compose exec -i pleroma_db psql -U pleroma -c "CREATE EXTENSION IF NOT EXISTS citext;"
docker-compose exec -i pleroma_db psql -U pleroma -c "CREATE EXTENSION IF NOT EXISTS pg_trgm;"
docker-compose exec -i pleroma_db psql -U pleroma -c 'CREATE EXTENSION IF NOT EXISTS "uuid-ossp";'
docker-compose down
docker buildx build -t pleroma_selfbuilt -f ./Dockerfile.pleroma .