Fix new config format
This commit is contained in:
parent
bdf83f7227
commit
3adfa6642f
@ -63,3 +63,7 @@ MIX_ENV=prod
|
||||
|
||||
# The git tag, revision, or branch to check out on build
|
||||
PLEROMA_VERSION=develop
|
||||
|
||||
# Domain to run at (only relevant for traefik mode)
|
||||
PLEROMA_URL=coolsite.moe
|
||||
PLEROMA_MEDIA_PROXY_URL=cdn.coolsite.moe
|
||||
|
57
Dockerfile
57
Dockerfile
@ -1,61 +1,67 @@
|
||||
FROM debian:9-slim
|
||||
|
||||
VOLUME /custom.d
|
||||
EXPOSE 4000
|
||||
|
||||
# Set up environment
|
||||
ENV DEBIAN_FRONTEND=noninteractive
|
||||
ENV LC_ALL=C.UTF-8
|
||||
ENV LANG=C.UTF-8
|
||||
|
||||
# Register pseudo-entrypoint
|
||||
ADD ./entrypoint.sh /
|
||||
# Prepare mounts and entrypoint
|
||||
VOLUME /custom.d
|
||||
VOLUME /conf
|
||||
|
||||
COPY ./entrypoint.sh /
|
||||
RUN chmod a+x /entrypoint.sh
|
||||
ENTRYPOINT ["/entrypoint.sh"]
|
||||
|
||||
# Get build dependencies
|
||||
# Expose default pleroma port to host
|
||||
EXPOSE 4000
|
||||
|
||||
# Get erlang, elixir, and dependencies
|
||||
RUN \
|
||||
apt-get update \
|
||||
&& apt-get install -y --no-install-recommends apt-utils \
|
||||
&& apt-get install -y --no-install-recommends git wget ca-certificates gnupg2 build-essential \
|
||||
&& apt-get install -y --no-install-recommends git wget ca-certificates gnupg2 build-essential ruby \
|
||||
\
|
||||
&& wget https://packages.erlang-solutions.com/erlang-solutions_1.0_all.deb \
|
||||
&& dpkg -i erlang-solutions_1.0_all.deb \
|
||||
&& apt-get update \
|
||||
&& apt-get install -y --no-install-recommends esl-erlang elixir \
|
||||
&& apt-get install -y ruby \
|
||||
\
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# Limit permissions
|
||||
ARG DOCKER_UID
|
||||
ARG DOCKER_GID
|
||||
ARG PLEROMA_UPLOADS_PATH
|
||||
ARG DOCKER_UID=1000
|
||||
ARG DOCKER_GID=1000
|
||||
ARG PLEROMA_UPLOADS_PATH=/uploads
|
||||
|
||||
RUN \
|
||||
groupadd --gid ${DOCKER_GID} pleroma \
|
||||
&& useradd -m -s /bin/bash --gid ${DOCKER_GID} --uid ${DOCKER_UID} pleroma \
|
||||
&& mkdir -p /custom.d $PLEROMA_UPLOADS_PATH \
|
||||
&& chown -R pleroma:pleroma /custom.d $PLEROMA_UPLOADS_PATH
|
||||
&& chown -R pleroma:pleroma /custom.d /conf $PLEROMA_UPLOADS_PATH
|
||||
|
||||
USER pleroma
|
||||
WORKDIR /home/pleroma
|
||||
|
||||
# Get pleroma
|
||||
# Get pleroma sources
|
||||
RUN git clone --progress https://git.pleroma.social/pleroma/pleroma.git ./pleroma
|
||||
WORKDIR /home/pleroma/pleroma
|
||||
|
||||
# Get rebar/hex
|
||||
# Bust the build cache (if needed)
|
||||
# This works by setting an environment variable with the last
|
||||
# used version/branch/tag/commitish/... which originates in the script.
|
||||
# If the host doesn't have the required tool for "smart version detection"
|
||||
# we'll just use the current timestamp here which forces a rebuild every time.
|
||||
ARG __BUST_CACHE
|
||||
ENV __BUST_CACHE $__BUST_CACHE
|
||||
|
||||
# Get rebar and hex
|
||||
RUN \
|
||||
mix local.hex --force \
|
||||
&& mix local.rebar --force
|
||||
|
||||
# Bust the build cache
|
||||
ARG __BUST_CACHE
|
||||
ENV __BUST_CACHE $__BUST_CACHE
|
||||
|
||||
# Fetch changes, checkout
|
||||
ARG PLEROMA_VERSION
|
||||
|
||||
RUN \
|
||||
git fetch --all \
|
||||
&& git checkout $PLEROMA_VERSION \
|
||||
@ -66,9 +72,12 @@ RUN \
|
||||
mix deps.get \
|
||||
&& mix compile
|
||||
|
||||
# Insert overrides and config helper
|
||||
COPY --chown=pleroma:pleroma ./docker-config.exs /docker-config.exs
|
||||
COPY --chown=pleroma:pleroma ./custom.d /home/pleroma/pleroma
|
||||
# Prepare runtime config
|
||||
RUN \
|
||||
ln -s /docker-config.exs config/prod.secret.exs \
|
||||
&& ln -s /docker-config.exs config/dev.secret.exs
|
||||
ln -sf runtime-config.exs config/prod.secret.exs \
|
||||
&& ln -sf runtime-config.exs config/dev.secret.exs
|
||||
|
||||
# Insert overrides
|
||||
COPY --chown=pleroma:pleroma ./custom.d /home/pleroma/pleroma
|
||||
|
||||
# Recompiles at runtime if custom.d contained elixir code.
|
||||
|
@ -6,22 +6,20 @@ version: 1
|
||||
# You can enter any config in here that you want.
|
||||
# Pleroma-Docker will try to translate it into elixir for you.
|
||||
#
|
||||
# For example:
|
||||
# <T> is a special member for modifying the YAML->Elixir translation.
|
||||
# When set to `Array` it causes the generation of a "keyed array" literal instead
|
||||
# of multiple named parameters to `config`.
|
||||
#
|
||||
# :foo:
|
||||
# Bar.Baz:
|
||||
# x: true
|
||||
# <D> is a special prefix that causes a string to be passed <D>irectly without quoting.
|
||||
# Useful for referencing modules like Ecto adapters or other symbols that are usually wrapped in yaml.
|
||||
#
|
||||
# becomes `config :foo, Bar.Baz, x: true`.
|
||||
#
|
||||
# It is assumed that all config keys that have to be passed through to
|
||||
# pleroma must start with an atom on the first layer (eg :pleroma).
|
||||
# Remember to take a look at your config with `./pleroma config`.
|
||||
#
|
||||
|
||||
app:
|
||||
# The loglevel to use in pleroma.
|
||||
:logger:
|
||||
level: info
|
||||
level: <D>:info
|
||||
|
||||
:pleroma:
|
||||
Pleroma.Repo:
|
||||
@ -32,6 +30,7 @@ app:
|
||||
password: pleroma
|
||||
database: pleroma
|
||||
pool_size: 16
|
||||
adapter: <D>Ecto.Adapters.Postgres
|
||||
|
||||
Pleroma.Web.Endpoint:
|
||||
# Location where your instance will be reachable.
|
||||
|
@ -3,6 +3,14 @@
|
||||
require 'yaml'
|
||||
require 'json'
|
||||
|
||||
def getval(val)
|
||||
if val.is_a?(String)
|
||||
val.start_with?('<D>') ? val.delete('<D>') : val.to_json()
|
||||
else
|
||||
val.to_json()
|
||||
end
|
||||
end
|
||||
|
||||
config = YAML.load_file(ARGV[0])
|
||||
|
||||
if config["version"] != 1
|
||||
@ -15,8 +23,8 @@ config["app"].each do |atom, content|
|
||||
content.each do |sub, settings|
|
||||
buf += "config :#{atom}, #{sub.is_a?(Symbol) ? ":#{sub}" : sub}"
|
||||
|
||||
if !settings.is_a? Hash
|
||||
buf += ": #{settings.to_json}\n"
|
||||
if !settings.is_a?(Hash)
|
||||
buf += ": #{getval(settings)}\n"
|
||||
next
|
||||
end
|
||||
|
||||
@ -27,13 +35,13 @@ config["app"].each do |atom, content|
|
||||
buf += ", #{name}: ["
|
||||
|
||||
value.each do |k, v|
|
||||
buf += "#{k}: #{v.to_json},"
|
||||
buf += "#{k}: #{getval(v)},"
|
||||
end
|
||||
buf.chop!
|
||||
buf.chop!()
|
||||
|
||||
buf += "]"
|
||||
else
|
||||
buf += ", #{name}: #{value.to_json}"
|
||||
buf += ", #{name}: #{getval(value)}"
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -4,7 +4,7 @@ set -e
|
||||
set -x
|
||||
|
||||
# Generate a config file
|
||||
ruby /config/parser.rb /config/config.yml > runtime-config.exs
|
||||
ruby /conf/parser.rb /conf/config.yml > config/runtime-config.exs
|
||||
|
||||
# Recompile if needed
|
||||
if [[ ! -z "$RECOMPILE" ]]; then
|
||||
|
41
pleroma
41
pleroma
@ -11,36 +11,38 @@ Usage:
|
||||
$0 [action]
|
||||
|
||||
Actions:
|
||||
build Rebuild the pleroma container.
|
||||
build Rebuild the pleroma container.
|
||||
|
||||
dump Dump the generated docker-compose.yml to stdout.
|
||||
config [file = config.yml] Print the generated pleroma config to stdout.
|
||||
|
||||
debug [bin] [args...] Launches a new pleroma container but uses \$bin instead of phx.server as entrypoint.
|
||||
**Warning**: This is intended for debugging pleroma with tools like :debugger and :observer.
|
||||
It thus forwards your X-Server into docker and temporarily fiddles with your xhost
|
||||
access controls. If this is a security concern for you, please export NO_X_FORWARDING=1
|
||||
before launching a debugger session.
|
||||
dump Dump the generated docker-compose.yml to stdout.
|
||||
|
||||
enter Spawn a shell inside the container for debugging/maintenance.
|
||||
This command does not link to the postgres container.
|
||||
If you need that use #debug instead.
|
||||
debug [bin] [args...] Launches a new pleroma container but uses \$bin instead of phx.server as entrypoint.
|
||||
**Warning**: This is intended for debugging pleroma with tools like :debugger and :observer.
|
||||
It thus forwards your X-Server into docker and temporarily fiddles with your xhost
|
||||
access controls. If this is a security concern for you, please export NO_X_FORWARDING=1
|
||||
before launching a debugger session.
|
||||
|
||||
logs Show the current container logs.
|
||||
enter Spawn a shell inside the container for debugging/maintenance.
|
||||
This command does not link to the postgres container.
|
||||
If you need that use #debug instead.
|
||||
|
||||
mix [task] [args...] Run a mix task without entering the container.
|
||||
logs Show the current container logs.
|
||||
|
||||
mod [file] Creates the file in custom.d and downloads the content from pleroma.social.
|
||||
The download respects your \$PLEROMA_VERSION from .env.
|
||||
mix [task] [args...] Run a mix task without entering the container.
|
||||
|
||||
passthrough / p [...] Pass any custom command to docker-compose.
|
||||
mod [file] Creates the file in custom.d and downloads the content from pleroma.social.
|
||||
The download respects your \$PLEROMA_VERSION from .env.
|
||||
|
||||
restart Executes #stop and #start respectively.
|
||||
passthrough / p [...] Pass any custom command to docker-compose.
|
||||
|
||||
start / up Start pleroma and sibling services.
|
||||
restart Executes #stop and #start respectively.
|
||||
|
||||
stop / down Stop pleroma and sibling services.
|
||||
start / up Start pleroma and sibling services.
|
||||
|
||||
status / ps Show the current container status.
|
||||
stop / down Stop pleroma and sibling services.
|
||||
|
||||
status / ps Show the current container status.
|
||||
|
||||
Environment:
|
||||
DEBUG can be used to modify the loglevel.
|
||||
@ -91,6 +93,7 @@ load_env() {
|
||||
}
|
||||
|
||||
action__build() { docker_compose build --build-arg __BUST_CACHE="$(date +%s)" server; }
|
||||
action__config() { docker run --rm -t -i -v $(pwd):/mnt ruby:alpine sh -c "cd /mnt && ruby config_parser/parser.rb ${1:-config.yml}"; }
|
||||
action__dump() { cat <(render_template); }
|
||||
action__enter() { docker_compose exec server ash -c 'cd /pleroma && ash'; }
|
||||
action__logs() { docker_compose logs -f; }
|
||||
|
Loading…
Reference in New Issue
Block a user