mirror of
https://github.com/correl/docker-pleroma.git
synced 2024-11-23 11:09:55 +00:00
Update Dockerfile, add docker-compose.yml, and config.exs (#25)
This commit is contained in:
parent
2ae758d3b3
commit
630114992b
3 changed files with 134 additions and 15 deletions
38
Dockerfile
38
Dockerfile
|
@ -4,16 +4,24 @@ ENV UID=911 GID=911 \
|
||||||
MIX_ENV=prod
|
MIX_ENV=prod
|
||||||
|
|
||||||
ARG PLEROMA_VER=develop
|
ARG PLEROMA_VER=develop
|
||||||
|
ENV UID=911 GID=911 MIX_ENV=prod
|
||||||
|
|
||||||
RUN apk -U upgrade \
|
ENV MIX_ENV=prod
|
||||||
&& apk add --no-cache \
|
|
||||||
build-base \
|
RUN echo "http://nl.alpinelinux.org/alpine/latest-stable/community" >> /etc/apk/repositories \
|
||||||
cmake \
|
&& apk update \
|
||||||
git \
|
&& apk add git gcc g++ musl-dev make cmake file-dev \
|
||||||
file-dev
|
exiftool imagemagick libmagic ncurses postgresql-client ffmpeg
|
||||||
|
|
||||||
RUN addgroup -g ${GID} pleroma \
|
RUN addgroup -g ${GID} pleroma \
|
||||||
&& adduser -h /pleroma -s /bin/sh -D -G pleroma -u ${UID} 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
|
USER pleroma
|
||||||
WORKDIR /pleroma
|
WORKDIR /pleroma
|
||||||
|
@ -21,13 +29,15 @@ WORKDIR /pleroma
|
||||||
RUN git clone -b develop https://git.pleroma.social/pleroma/pleroma.git /pleroma \
|
RUN git clone -b develop https://git.pleroma.social/pleroma/pleroma.git /pleroma \
|
||||||
&& git checkout ${PLEROMA_VER}
|
&& git checkout ${PLEROMA_VER}
|
||||||
|
|
||||||
COPY config/secret.exs /pleroma/config/prod.secret.exs
|
RUN echo "import Mix.Config" > config/prod.secret.exs \
|
||||||
|
|
||||||
RUN mix local.rebar --force \
|
|
||||||
&& mix local.hex --force \
|
&& mix local.hex --force \
|
||||||
&& mix deps.get \
|
&& mix local.rebar --force \
|
||||||
&& mix compile
|
&& mix deps.get --only prod \
|
||||||
|
&& mkdir release \
|
||||||
|
&& mix release --path /pleroma
|
||||||
|
|
||||||
VOLUME /pleroma/uploads/
|
COPY ./config.exs /etc/pleroma/config.exs
|
||||||
|
|
||||||
CMD ["mix", "phx.server"]
|
EXPOSE 4000
|
||||||
|
|
||||||
|
ENTRYPOINT ["/pleroma/docker-entrypoint.sh"]
|
74
config.exs
Normal file
74
config.exs
Normal file
|
@ -0,0 +1,74 @@
|
||||||
|
import Config
|
||||||
|
|
||||||
|
config :pleroma, Pleroma.Web.Endpoint,
|
||||||
|
url: [host: System.get_env("DOMAIN", "localhost"), scheme: "https", port: 443],
|
||||||
|
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
|
||||||
|
""")
|
35
docker-compose.yml
Normal file
35
docker-compose.yml
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
version: '3.8'
|
||||||
|
|
||||||
|
services:
|
||||||
|
db:
|
||||||
|
image: postgres:12.1-alpine
|
||||||
|
container_name: pleroma_db
|
||||||
|
restart: always
|
||||||
|
environment:
|
||||||
|
POSTGRES_USER: pleroma
|
||||||
|
POSTGRES_PASSWORD: ChangeMe!
|
||||||
|
POSTGRES_DB: pleroma
|
||||||
|
volumes:
|
||||||
|
- ./postgres:/var/lib/postgresql/data
|
||||||
|
|
||||||
|
web:
|
||||||
|
build: .
|
||||||
|
image: pleroma
|
||||||
|
container_name: pleroma_web
|
||||||
|
restart: always
|
||||||
|
ports:
|
||||||
|
- '4000:4000'
|
||||||
|
volumes:
|
||||||
|
- ./uploads:/var/lib/pleroma/uploads
|
||||||
|
- ./static:/var/lib/pleroma/static
|
||||||
|
- ./config.exs:/etc/pleroma/config.exs:ro
|
||||||
|
environment:
|
||||||
|
DOMAIN: exmaple.com
|
||||||
|
INSTANCE_NAME: Pleroma
|
||||||
|
ADMIN_EMAIL: admin@example.com
|
||||||
|
NOTIFY_EMAIL: notify@example.com
|
||||||
|
DB_USER: pleroma
|
||||||
|
DB_PASS: ChangeMe!
|
||||||
|
DB_NAME: pleroma
|
||||||
|
depends_on:
|
||||||
|
- db
|
Loading…
Reference in a new issue