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
|
# The git tag, revision, or branch to check out on build
|
||||||
PLEROMA_VERSION=develop
|
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
|
FROM debian:9-slim
|
||||||
|
|
||||||
VOLUME /custom.d
|
# Set up environment
|
||||||
EXPOSE 4000
|
|
||||||
|
|
||||||
ENV DEBIAN_FRONTEND=noninteractive
|
ENV DEBIAN_FRONTEND=noninteractive
|
||||||
ENV LC_ALL=C.UTF-8
|
ENV LC_ALL=C.UTF-8
|
||||||
ENV LANG=C.UTF-8
|
ENV LANG=C.UTF-8
|
||||||
|
|
||||||
# Register pseudo-entrypoint
|
# Prepare mounts and entrypoint
|
||||||
ADD ./entrypoint.sh /
|
VOLUME /custom.d
|
||||||
|
VOLUME /conf
|
||||||
|
|
||||||
|
COPY ./entrypoint.sh /
|
||||||
RUN chmod a+x /entrypoint.sh
|
RUN chmod a+x /entrypoint.sh
|
||||||
ENTRYPOINT ["/entrypoint.sh"]
|
ENTRYPOINT ["/entrypoint.sh"]
|
||||||
|
|
||||||
# Get build dependencies
|
# Expose default pleroma port to host
|
||||||
|
EXPOSE 4000
|
||||||
|
|
||||||
|
# Get erlang, elixir, and dependencies
|
||||||
RUN \
|
RUN \
|
||||||
apt-get update \
|
apt-get update \
|
||||||
&& apt-get install -y --no-install-recommends apt-utils \
|
&& 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 \
|
&& wget https://packages.erlang-solutions.com/erlang-solutions_1.0_all.deb \
|
||||||
&& dpkg -i erlang-solutions_1.0_all.deb \
|
&& dpkg -i erlang-solutions_1.0_all.deb \
|
||||||
&& apt-get update \
|
&& apt-get update \
|
||||||
&& apt-get install -y --no-install-recommends esl-erlang elixir \
|
&& apt-get install -y --no-install-recommends esl-erlang elixir \
|
||||||
&& apt-get install -y ruby \
|
|
||||||
\
|
\
|
||||||
&& rm -rf /var/lib/apt/lists/*
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
# Limit permissions
|
# Limit permissions
|
||||||
ARG DOCKER_UID
|
ARG DOCKER_UID=1000
|
||||||
ARG DOCKER_GID
|
ARG DOCKER_GID=1000
|
||||||
ARG PLEROMA_UPLOADS_PATH
|
ARG PLEROMA_UPLOADS_PATH=/uploads
|
||||||
|
|
||||||
RUN \
|
RUN \
|
||||||
groupadd --gid ${DOCKER_GID} pleroma \
|
groupadd --gid ${DOCKER_GID} pleroma \
|
||||||
&& useradd -m -s /bin/bash --gid ${DOCKER_GID} --uid ${DOCKER_UID} pleroma \
|
&& useradd -m -s /bin/bash --gid ${DOCKER_GID} --uid ${DOCKER_UID} pleroma \
|
||||||
&& mkdir -p /custom.d $PLEROMA_UPLOADS_PATH \
|
&& 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
|
USER pleroma
|
||||||
WORKDIR /home/pleroma
|
WORKDIR /home/pleroma
|
||||||
|
|
||||||
# Get pleroma
|
# Get pleroma sources
|
||||||
RUN git clone --progress https://git.pleroma.social/pleroma/pleroma.git ./pleroma
|
RUN git clone --progress https://git.pleroma.social/pleroma/pleroma.git ./pleroma
|
||||||
WORKDIR /home/pleroma/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 \
|
RUN \
|
||||||
mix local.hex --force \
|
mix local.hex --force \
|
||||||
&& mix local.rebar --force
|
&& mix local.rebar --force
|
||||||
|
|
||||||
# Bust the build cache
|
|
||||||
ARG __BUST_CACHE
|
|
||||||
ENV __BUST_CACHE $__BUST_CACHE
|
|
||||||
|
|
||||||
# Fetch changes, checkout
|
# Fetch changes, checkout
|
||||||
ARG PLEROMA_VERSION
|
ARG PLEROMA_VERSION
|
||||||
|
|
||||||
RUN \
|
RUN \
|
||||||
git fetch --all \
|
git fetch --all \
|
||||||
&& git checkout $PLEROMA_VERSION \
|
&& git checkout $PLEROMA_VERSION \
|
||||||
@ -66,9 +72,12 @@ RUN \
|
|||||||
mix deps.get \
|
mix deps.get \
|
||||||
&& mix compile
|
&& mix compile
|
||||||
|
|
||||||
# Insert overrides and config helper
|
# Prepare runtime config
|
||||||
COPY --chown=pleroma:pleroma ./docker-config.exs /docker-config.exs
|
|
||||||
COPY --chown=pleroma:pleroma ./custom.d /home/pleroma/pleroma
|
|
||||||
RUN \
|
RUN \
|
||||||
ln -s /docker-config.exs config/prod.secret.exs \
|
ln -sf runtime-config.exs config/prod.secret.exs \
|
||||||
&& ln -s /docker-config.exs config/dev.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.
|
# You can enter any config in here that you want.
|
||||||
# Pleroma-Docker will try to translate it into elixir for you.
|
# 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:
|
# <D> is a special prefix that causes a string to be passed <D>irectly without quoting.
|
||||||
# Bar.Baz:
|
# Useful for referencing modules like Ecto adapters or other symbols that are usually wrapped in yaml.
|
||||||
# x: true
|
|
||||||
#
|
#
|
||||||
# becomes `config :foo, Bar.Baz, x: true`.
|
# Remember to take a look at your config with `./pleroma config`.
|
||||||
#
|
|
||||||
# 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).
|
|
||||||
#
|
#
|
||||||
|
|
||||||
app:
|
app:
|
||||||
# The loglevel to use in pleroma.
|
# The loglevel to use in pleroma.
|
||||||
:logger:
|
:logger:
|
||||||
level: info
|
level: <D>:info
|
||||||
|
|
||||||
:pleroma:
|
:pleroma:
|
||||||
Pleroma.Repo:
|
Pleroma.Repo:
|
||||||
@ -32,6 +30,7 @@ app:
|
|||||||
password: pleroma
|
password: pleroma
|
||||||
database: pleroma
|
database: pleroma
|
||||||
pool_size: 16
|
pool_size: 16
|
||||||
|
adapter: <D>Ecto.Adapters.Postgres
|
||||||
|
|
||||||
Pleroma.Web.Endpoint:
|
Pleroma.Web.Endpoint:
|
||||||
# Location where your instance will be reachable.
|
# Location where your instance will be reachable.
|
||||||
|
@ -3,6 +3,14 @@
|
|||||||
require 'yaml'
|
require 'yaml'
|
||||||
require 'json'
|
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])
|
config = YAML.load_file(ARGV[0])
|
||||||
|
|
||||||
if config["version"] != 1
|
if config["version"] != 1
|
||||||
@ -15,8 +23,8 @@ config["app"].each do |atom, content|
|
|||||||
content.each do |sub, settings|
|
content.each do |sub, settings|
|
||||||
buf += "config :#{atom}, #{sub.is_a?(Symbol) ? ":#{sub}" : sub}"
|
buf += "config :#{atom}, #{sub.is_a?(Symbol) ? ":#{sub}" : sub}"
|
||||||
|
|
||||||
if !settings.is_a? Hash
|
if !settings.is_a?(Hash)
|
||||||
buf += ": #{settings.to_json}\n"
|
buf += ": #{getval(settings)}\n"
|
||||||
next
|
next
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -27,13 +35,13 @@ config["app"].each do |atom, content|
|
|||||||
buf += ", #{name}: ["
|
buf += ", #{name}: ["
|
||||||
|
|
||||||
value.each do |k, v|
|
value.each do |k, v|
|
||||||
buf += "#{k}: #{v.to_json},"
|
buf += "#{k}: #{getval(v)},"
|
||||||
end
|
end
|
||||||
buf.chop!
|
buf.chop!()
|
||||||
|
|
||||||
buf += "]"
|
buf += "]"
|
||||||
else
|
else
|
||||||
buf += ", #{name}: #{value.to_json}"
|
buf += ", #{name}: #{getval(value)}"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@ set -e
|
|||||||
set -x
|
set -x
|
||||||
|
|
||||||
# Generate a config file
|
# 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
|
# Recompile if needed
|
||||||
if [[ ! -z "$RECOMPILE" ]]; then
|
if [[ ! -z "$RECOMPILE" ]]; then
|
||||||
|
3
pleroma
3
pleroma
@ -13,6 +13,8 @@ Usage:
|
|||||||
Actions:
|
Actions:
|
||||||
build Rebuild the pleroma container.
|
build Rebuild the pleroma container.
|
||||||
|
|
||||||
|
config [file = config.yml] Print the generated pleroma config to stdout.
|
||||||
|
|
||||||
dump Dump the generated docker-compose.yml to stdout.
|
dump Dump the generated docker-compose.yml to stdout.
|
||||||
|
|
||||||
debug [bin] [args...] Launches a new pleroma container but uses \$bin instead of phx.server as entrypoint.
|
debug [bin] [args...] Launches a new pleroma container but uses \$bin instead of phx.server as entrypoint.
|
||||||
@ -91,6 +93,7 @@ load_env() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
action__build() { docker_compose build --build-arg __BUST_CACHE="$(date +%s)" server; }
|
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__dump() { cat <(render_template); }
|
||||||
action__enter() { docker_compose exec server ash -c 'cd /pleroma && ash'; }
|
action__enter() { docker_compose exec server ash -c 'cd /pleroma && ash'; }
|
||||||
action__logs() { docker_compose logs -f; }
|
action__logs() { docker_compose logs -f; }
|
||||||
|
Loading…
Reference in New Issue
Block a user