All dem environment variables

This commit is contained in:
sn0w 2018-04-08 16:15:44 +02:00
parent d5ad29eef4
commit 39f841ad57
5 changed files with 97 additions and 15 deletions

View File

@ -10,3 +10,16 @@ DOCKER_DATADIR=
POSTGRES_DB=
POSTGRES_USER=
POSTGRES_PASSWORD=
# Pleroma Settings
PLEROMA_URL=
PLEROMA_SCHEME=
PLEROMA_PORT=
PLEROMA_SECRET_KEY_BASE=
PLEROMA_NAME=
PLEROMA_ADMIN_EMAIL=
PLEROMA_USER_LIMIT=
PLEROMA_REGISTRATIONS_OPEN=
PLEROMA_MEDIA_PROXY_ENABLED=
PLEROMA_MEDIA_PROXY_REDIRECT_ON_FAILURE=
PLEROMA_MEDIA_PROXY_URL=

View File

@ -3,18 +3,18 @@ version: "3"
networks:
default:
external:
name: ${DOCKER_NETWORK}
name: ${DOCKER_NETWORK:?DOCKER_NETWORK}
services:
db:
image: postgres:10.3-alpine
restart: unless-stopped
environment:
POSTGRES_DB: ${POSTGRES_DB}
POSTGRES_USER: ${POSTGRES_USER}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
POSTGRES_DB: ${POSTGRES_DB:?POSTGRES_DB}
POSTGRES_USER: ${POSTGRES_USER:?POSTGRES_USER}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:?POSTGRES_PASSWORD}
volumes:
- ${DOCKER_DATADIR}/db:/var/lib/postgresql/data
- ${DOCKER_DATADIR:?DOCKER_DATADIR}/db:/var/lib/postgresql/data
server:
build:
@ -25,15 +25,40 @@ services:
- db
environment:
POSTGRES_IP: db
POSTGRES_DB: ${POSTGRES_DB}
POSTGRES_USER: ${POSTGRES_USER}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
POSTGRES_DB: ${POSTGRES_DB:?POSTGRES_DB}
POSTGRES_USER: ${POSTGRES_USER:?POSTGRES_USER}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:?POSTGRES_PASSWORD}
PLEROMA_URL: ${PLEROMA_URL:?PLEROMA_URL}
PLEROMA_SCHEME: ${PLEROMA_SCHEME:?PLEROMA_SCHEME}
PLEROMA_PORT: ${PLEROMA_PORT:?PLEROMA_PORT}
PLEROMA_SECRET_KEY_BASE: ${PLEROMA_SECRET_KEY_BASE:?PLEROMA_SECRET_KEY_BASE}
PLEROMA_NAME: ${PLEROMA_NAME:?PLEROMA_NAME}
PLEROMA_ADMIN_EMAIL: ${PLEROMA_ADMIN_EMAIL:?PLEROMA_ADMIN_EMAIL}
PLEROMA_USER_LIMIT: ${PLEROMA_USER_LIMIT:?PLEROMA_USER_LIMIT}
PLEROMA_REGISTRATIONS_OPEN: ${PLEROMA_REGISTRATIONS_OPEN:?PLEROMA_REGISTRATIONS_OPEN}
PLEROMA_MEDIA_PROXY_ENABLED: ${PLEROMA_MEDIA_PROXY_ENABLED:?PLEROMA_MEDIA_PROXY_ENABLED}
PLEROMA_MEDIA_PROXY_REDIRECT_ON_FAILURE: ${PLEROMA_MEDIA_PROXY_REDIRECT_ON_FAILURE:?PLEROMA_MEDIA_PROXY_REDIRECT_ON_FAILURE}
PLEROMA_MEDIA_PROXY_URL: ${PLEROMA_MEDIA_PROXY_URL:?PLEROMA_MEDIA_PROXY_URL}
PLEROMA_WORKSPACE: /pleroma
MIX_ARCHIVES: /mix/archives
MIX_HOME: /mix/home
MIX_ENV: prod
volumes:
- ./pleroma:/pleroma
- ${DOCKER_DATADIR}/pleroma:/data
- ${DOCKER_DATADIR}/mix:/mix
- ${DOCKER_DATADIR}/misc/cache:/root/.cache
- ${DOCKER_DATADIR}/misc/meta:/meta
- ${DOCKER_DATADIR:?DOCKER_DATADIR}/pleroma:/data
- ${DOCKER_DATADIR:?DOCKER_DATADIR}/mix:/mix
- ${DOCKER_DATADIR:?DOCKER_DATADIR}/misc/cache:/root/.cache
- ${DOCKER_DATADIR:?DOCKER_DATADIR}/misc/meta:/meta
labels:
traefik.enable: "true"
traefik.fe.port: "4000"
traefik.fe.protocol: "http"
traefik.fe.entryPoints: "http,https"
traefik.fe.frontend.rule: "Host:${PLEROMA_URL:?PLEROMA_URL}"
traefik.cache.port: "80"
traefik.cache.protocol: "http"
traefik.cache.entryPoints: "http,https"
traefik.cache.frontend.rule: "Host:${PLEROMA_MEDIA_PROXY_URL:?PLEROMA_MEDIA_PROXY_URL}"

33
docker-config.exs Normal file
View File

@ -0,0 +1,33 @@
use Mix.Config
env = fn name ->
env_name = "pleroma_" <> Atom.to_string(name) |> String.upcase
System.get_env(env_name) || raise "Could not find #{env_name} in environment. Please define it and try again."
end
config :pleroma, Pleroma.Web.Endpoint,
url: [
host: env.(:url),
scheme: env.(:scheme),
port: env.(:port)
],
secret_key_base: env.(:secret_key_base)
config :pleroma, :instance,
name: env.(:name),
email: env.(:admin_email),
limit: env.(:user_limit),
registrations_open: env.(:registrations_open)
config :pleroma, :media_proxy,
enabled: env.(:media_proxy_enabled),
redirect_on_failure: env.(:media_proxy_redirect_on_failure),
base_url: env.(:media_proxy_url)
config :pleroma, Pleroma.Repo,
adapter: Ecto.Adapters.Postgres,
username: env.(:db_user),
password: env.(:db_pass),
database: env.(:db_name),
hostname: env.(:db_host),
pool_size: env.(:db_pool_size)

View File

@ -32,7 +32,16 @@ if [[ -z "$PLEROMA_WORKSPACE" ]]; then
echo "Please set the PLEROMA_WORKSPACE variable to your pleroma root."
exit 1
fi
cd $PLEROMA_WORKSPACE
if [[ ! -L config/prod.secret.exs ]]; then
rm -f config/prod.secret.exs
ln -s /docker-config.exs config/prod.secret.exs
fi
if [[ ! -L config/dev.secret.exs ]]; then
rm -f config/dev.secret.exs
ln -s /docker-config.exs config/dev.secret.exs
fi
case "$1" in
build) action__build;;

View File

@ -2,9 +2,11 @@ FROM elixir:1.6-alpine
RUN apk add --no-cache --virtual .build alpine-sdk git
ADD ./entrypoint.sh /
RUN chmod +x /entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"]
ADD ./docker-config.exs /docker-config.exs
ADD ./entrypoint.ash /
RUN chmod +x /entrypoint.ash
ENTRYPOINT ["/entrypoint.ash"]
CMD ["run"]
EXPOSE 4000