Initial commit
This commit is contained in:
commit
a785e9eff5
3
.gitignore
vendored
Normal file
3
.gitignore
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
# In case you end up running it from this repository
|
||||||
|
.env
|
||||||
|
data
|
28
Dockerfile
Normal file
28
Dockerfile
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
FROM alpine
|
||||||
|
|
||||||
|
# Install packages
|
||||||
|
RUN awk 'NR==2' /etc/apk/repositories | sed 's/main/community/' | tee -a /etc/apk/repositories
|
||||||
|
RUN apk update && apk add curl exiftool ffmpeg imagemagick libmagic openssl1.1-compat postgresql14-client su-exec unzip
|
||||||
|
|
||||||
|
# Create user and directories
|
||||||
|
RUN addgroup pleroma && adduser --system -G pleroma --shell /bin/false --home /opt/pleroma pleroma
|
||||||
|
RUN mkdir -p /uploads
|
||||||
|
RUN mkdir -p /static
|
||||||
|
RUN mkdir -p /config
|
||||||
|
|
||||||
|
# Download and install Pleroma
|
||||||
|
RUN curl 'https://git.pleroma.social/api/v4/projects/2/jobs/artifacts/stable/download?job=amd64-musl' -o /tmp/pleroma.zip
|
||||||
|
RUN unzip /tmp/pleroma.zip -d /tmp/
|
||||||
|
RUN mv /tmp/release/* /opt/pleroma
|
||||||
|
RUN rmdir /tmp/release && rm /tmp/pleroma.zip
|
||||||
|
|
||||||
|
# Add entrypoint script and base config
|
||||||
|
COPY ./docker-entrypoint.sh /usr/local/bin/
|
||||||
|
COPY ./config.dist.exs /opt/pleroma/
|
||||||
|
|
||||||
|
WORKDIR /opt/pleroma
|
||||||
|
ENV PLEROMA_CONFIG_PATH=/config/config.exs
|
||||||
|
VOLUME ["/uploads", "/static", "/config"]
|
||||||
|
EXPOSE 4000
|
||||||
|
ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"]
|
||||||
|
CMD ["/opt/pleroma/bin/pleroma", "start"]
|
67
README.rst
Normal file
67
README.rst
Normal file
@ -0,0 +1,67 @@
|
|||||||
|
Docker image of Pleroma
|
||||||
|
=======================
|
||||||
|
|
||||||
|
This is a Pleroma image that I created for myself. Feel free to use it if you wish.
|
||||||
|
|
||||||
|
This image will create the configuration for Pleroma, and then migrate the configuration to the database.
|
||||||
|
|
||||||
|
Set Up
|
||||||
|
------
|
||||||
|
|
||||||
|
You'll need an environment file and a Compose file.
|
||||||
|
|
||||||
|
|
||||||
|
.env
|
||||||
|
~~~~
|
||||||
|
|
||||||
|
.. code-block:: shell
|
||||||
|
|
||||||
|
POSTGRES_HOST=postgres
|
||||||
|
POSTGRES_USER=pleroma
|
||||||
|
POSTGRES_PASSWORD=pleroma
|
||||||
|
POSTGRES_DB=pleroma
|
||||||
|
DOMAIN=pleroma.yourdomain.com
|
||||||
|
PORT=443
|
||||||
|
SCHEME=https
|
||||||
|
INSTANCE_NAME=Pleroma
|
||||||
|
ADMIN_EMAIL=admin@yourdomain.com
|
||||||
|
NOTIFY_EMAIL=notify@yourdomain.com
|
||||||
|
|
||||||
|
docker-compose.yaml
|
||||||
|
~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
.. code-block:: yaml
|
||||||
|
|
||||||
|
version: '3'
|
||||||
|
services:
|
||||||
|
postgres:
|
||||||
|
image: postgres:14
|
||||||
|
environment:
|
||||||
|
- POSTGRES_USER=${POSTGRES_USER:-pleroma}
|
||||||
|
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
|
||||||
|
- POSTGRES_DB=${POSTGRES_DB:-pleroma}
|
||||||
|
restart: unless-stopped
|
||||||
|
volumes:
|
||||||
|
- "./data/postgres:/var/lib/postgresql"
|
||||||
|
pleroma:
|
||||||
|
image: raoulsnyman/pleroma:latest
|
||||||
|
environment:
|
||||||
|
- POSTGRES_HOST=${POSTGRES_HOST:-postgres}
|
||||||
|
- POSTGRES_USER=${POSTGRES_USER:-pleroma}
|
||||||
|
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
|
||||||
|
- POSTGRES_DB=${POSTGRES_DB:-pleroma}
|
||||||
|
- DOMAIN=${DOMAIN:-localhost}
|
||||||
|
- SCHEME=${SCHEME:-http}
|
||||||
|
- PORT=${PORT:-8001}
|
||||||
|
- ADMIN_EMAIL=${ADMIN_EMAIL:-info@example.com}
|
||||||
|
- NOTIFY_EMAIL=${NOTIFY_EMAIL:-info@example.com}
|
||||||
|
- INSTANCE_NAME=${INSTANCE_NAME:-Pleroma}
|
||||||
|
restart: unless-stopped
|
||||||
|
volumes:
|
||||||
|
- "./data/config:/config"
|
||||||
|
- "./data/static:/static"
|
||||||
|
- "./data/uploads:/uploads"
|
||||||
|
ports:
|
||||||
|
- "127.0.0.1:8001:4000"
|
||||||
|
depends_on:
|
||||||
|
- postgres
|
67
config.dist.exs
Normal file
67
config.dist.exs
Normal file
@ -0,0 +1,67 @@
|
|||||||
|
import Config
|
||||||
|
|
||||||
|
config :pleroma, Pleroma.Web.Endpoint,
|
||||||
|
url: [host: System.get_env("DOMAIN", "localhost"), scheme: System.get_env("SCHEME", "http"), port: System.get_env("PORT", "8001")],
|
||||||
|
http: [ip: {0, 0, 0, 0}, port: 4000]
|
||||||
|
|
||||||
|
config :pleroma, :instance,
|
||||||
|
name: System.get_env("INSTANCE_NAME", "Pleroma"),
|
||||||
|
email: System.get_env("ADMIN_EMAIL", "info@example.com"),
|
||||||
|
notify_email: System.get_env("NOTIFY_EMAIL", "info@example.com"),
|
||||||
|
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("POSTGRES_USER", "pleroma"),
|
||||||
|
password: System.fetch_env!("POSTGRES_PASSWORD"),
|
||||||
|
database: System.get_env("POSTGRES_DB", "pleroma"),
|
||||||
|
hostname: System.get_env("POSTGRES_HOST", "postgres"),
|
||||||
|
pool_size: 10
|
||||||
|
|
||||||
|
config :web_push_encryption, :vapid_details, subject: "mailto:#{System.get_env("NOTIFY_EMAIL")}"
|
||||||
|
|
||||||
|
config :pleroma, :database, rum_enabled: false
|
||||||
|
config :pleroma, :instance, static_dir: "/static"
|
||||||
|
config :pleroma, Pleroma.Uploaders.Local, uploads: "/uploads"
|
||||||
|
|
||||||
|
if not File.exists?("/config/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("/config/secret.exs", secret_file)
|
||||||
|
end
|
||||||
|
|
||||||
|
import_config("/config/secret.exs")
|
||||||
|
|
||||||
|
# For additional user config
|
||||||
|
if File.exists?("/config/config-override.exs") do
|
||||||
|
import_config("/config/config-override.exs")
|
||||||
|
end
|
34
docker-compose.yaml
Normal file
34
docker-compose.yaml
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
version: '3'
|
||||||
|
services:
|
||||||
|
postgres:
|
||||||
|
image: postgres:14
|
||||||
|
environment:
|
||||||
|
- POSTGRES_USER=${POSTGRES_USER:-pleroma}
|
||||||
|
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
|
||||||
|
- POSTGRES_DB=${POSTGRES_DB:-pleroma}
|
||||||
|
restart: unless-stopped
|
||||||
|
volumes:
|
||||||
|
- "./data/postgres:/var/lib/postgresql"
|
||||||
|
pleroma:
|
||||||
|
build:
|
||||||
|
context: .
|
||||||
|
environment:
|
||||||
|
- POSTGRES_HOST=${POSTGRES_HOST:-postgres}
|
||||||
|
- POSTGRES_USER=${POSTGRES_USER:-pleroma}
|
||||||
|
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
|
||||||
|
- POSTGRES_DB=${POSTGRES_DB:-pleroma}
|
||||||
|
- DOMAIN=${DOMAIN:-localhost}
|
||||||
|
- SCHEME=${SCHEME:-http}
|
||||||
|
- PORT=${PORT:-8001}
|
||||||
|
- ADMIN_EMAIL=${ADMIN_EMAIL:-info@example.com}
|
||||||
|
- NOTIFY_EMAIL=${NOTIFY_EMAIL:-info@example.com}
|
||||||
|
- INSTANCE_NAME=${INSTANCE_NAME:-Pleroma}
|
||||||
|
restart: unless-stopped
|
||||||
|
volumes:
|
||||||
|
- "./data/config:/config"
|
||||||
|
- "./data/static:/static"
|
||||||
|
- "./data/uploads:/uploads"
|
||||||
|
ports:
|
||||||
|
- "127.0.0.1:8001:4000"
|
||||||
|
depends_on:
|
||||||
|
- postgres
|
25
docker-entrypoint.sh
Executable file
25
docker-entrypoint.sh
Executable file
@ -0,0 +1,25 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
set -e
|
||||||
|
|
||||||
|
# Wait for DB
|
||||||
|
while ! pg_isready -U ${POSTGRES_USER:-pleroma} -d postgres://${POSTGRES_HOST:-postgres}:${POSTGRES_PORT:-5432}/${POSTGRES_DB:-pleroma} -t 1; do
|
||||||
|
echo "Waiting for ${POSTGRES_HOST} to come up..."
|
||||||
|
sleep 1
|
||||||
|
done
|
||||||
|
|
||||||
|
# Fix the user on the config directory and re-run the script as the pleroma user
|
||||||
|
chown pleroma:pleroma -R /config /uploads /static /opt/pleroma
|
||||||
|
|
||||||
|
# Create config file, if necessary
|
||||||
|
if [ ! -f "/config/config.exs" ]; then
|
||||||
|
/sbin/su-exec pleroma cp /opt/pleroma/config.dist.exs /config/config.exs
|
||||||
|
/sbin/su-exec pleroma /opt/pleroma/bin/pleroma_ctl migrate
|
||||||
|
/sbin/su-exec pleroma /opt/pleroma/bin/pleroma_ctl config migrate_to_db
|
||||||
|
/sbin/su-exec pleroma echo "config :pleroma, configurable_from_database: true" >> /config/config.exs
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Migrate database
|
||||||
|
/sbin/su-exec pleroma /opt/pleroma/bin/pleroma_ctl migrate
|
||||||
|
|
||||||
|
# Run Pleroma as the "pleroma" user
|
||||||
|
exec /sbin/su-exec pleroma "$@"
|
10
example.env
Normal file
10
example.env
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
POSTGRES_HOST=postgres
|
||||||
|
POSTGRES_USER=pleroma
|
||||||
|
POSTGRES_PASSWORD=pleroma
|
||||||
|
POSTGRES_DB=pleroma
|
||||||
|
DOMAIN=pleroma.example.com
|
||||||
|
PORT=443
|
||||||
|
SCHEME=https
|
||||||
|
INSTANCE_NAME=Pleroma
|
||||||
|
ADMIN_EMAIL=info@example.com
|
||||||
|
NOTIFY_EMAIL=info@example.com
|
Loading…
Reference in New Issue
Block a user