Skip to content

Instantly share code, notes, and snippets.

@angristan
Created April 7, 2018 09:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save angristan/9013e5c479dfd1a24fa4c3ef6edcb8a9 to your computer and use it in GitHub Desktop.
Save angristan/9013e5c479dfd1a24fa4c3ef6edcb8a9 to your computer and use it in GitHub Desktop.
Pleroma dockerfiles drafts
version: '2.3'
services:
db:
restart: always
container_name: pleroma_postgres
image: postgres:9.6-alpine
volumes:
- ./postgres:/var/lib/postgresql/data
web:
build: .
image: pleroma
container_name: pleroma_web
restart: always
command: mix phx.server
ports:
- "127.0.0.1:4004:4000"
depends_on:
- db
volumes:
- ./uploads:/pleroma/uploads
#- ./config/emoji.txt:/pleroma/config/emoji.txt
#- ./config/prod.secret.exs:/pleroma/config/dev.secret.exs both to add after generating the conf
#environment:
# MIX_ENV: prod # breaks everything
FROM elixir:1.6.4-alpine
ENV UID=911 GID=911
RUN apk -U upgrade \
&& apk add \
build-base \
wget \
git \
&& rm -rf /tmp/* /var/cache/apk/*
RUN addgroup -g ${GID} pleroma \
&& adduser -h /pleroma -s /bin/sh -D -G pleroma -u ${UID} pleroma
USER pleroma
WORKDIR pleroma
RUN git clone -b develop https://git.pleroma.social/pleroma/pleroma.git /pleroma
COPY config/prod.secret.exs config/prod.secret.exs
RUN mix local.rebar --force \
&& mix local.hex --force \
&& mix deps.get \
&& mix compile
RUN mkdir /pleroma/uploads
VOLUME /pleroma/uploads/
FROM elixir:1.6.4
ENV UID=911 GID=911
RUN addgroup --GID ${GID} pleroma \
&& adduser --uid ${UID} --gid ${GID} \
--home /pleroma --shell /bin/sh \
--disabled-password --gecos "" pleroma
USER pleroma
WORKDIR pleroma
RUN wget -qO- https://git.pleroma.social/pleroma/pleroma/repository/develop/archive.tar.gz | tar xz --strip 1
COPY config/prod.secret.exs config/prod.secret.exs
RUN mix local.rebar --force \
&& mix local.hex --force \
&& mix deps.get \
&& mix compile
RUN mkdir /pleroma/uploads
VOLUME /pleroma/uploads/

Using an archive or git clone is the same in both

It's impossible to build an image with MIX_ENV=prod

The worst part comes after building the images and actually setting up pleroma

docker-compose run web mix generate_config

mkdir config
docker exec -i pleroma_web_run_1 cat config/generated_config.exs > config/prod.secret.ex
docker exec -i pleroma_web_run_1 cat config/setup_db.psql > config/setup_db.psql
docker exec -i pleroma_web_run_1 cat config/emoji.txt > config/emoji.txt

docker exec -i pleroma_postgres psql -U postgres < config/setup_db.psql

docker-compose run --rm web mix ecto.migrate WILL FAIL è_è

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment