Skip to content

Commit

Permalink
docker: Fix duplicate config files (#1442)
Browse files Browse the repository at this point in the history
* Because make was run before creating the config files, Zotonic generated
  default config files in the default locations, that then became used
  when starting Zotonic.
* This PR adds a default zotonic.config that is copied before make.
  Bonus: less sed’ing necessary.
  • Loading branch information
ddeboer committed Sep 22, 2016
1 parent 2efaa34 commit e9fae70
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 12 deletions.
12 changes: 6 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@ FROM alpine:3.4
ADD . /opt/zotonic
WORKDIR /opt/zotonic

COPY docker/zotonic.config /etc/zotonic/zotonic.config

RUN sed -f docker/erlang.config.sed priv/erlang.config.in > /etc/zotonic/erlang.config \
&& adduser -S -h /tmp -H -D zotonic \
&& chown -R zotonic /opt/zotonic/priv

# Note: dumb-init and gosu are pulled from edge; remove that when upgrading to an alpine release that
# includes those packages.
RUN apk add --virtual build-deps --no-cache ca-certificates wget curl make gcc musl-dev g++ bsd-compat-headers git \
Expand All @@ -13,15 +19,9 @@ RUN apk add --virtual build-deps --no-cache ca-certificates wget curl make gcc m
&& DEBUG=1 make \
&& apk del build-deps

RUN mkdir /etc/zotonic \
&& sed -f docker/erlang.config.sed priv/erlang.config.in > /etc/zotonic/erlang.config \
&& adduser -S -h /tmp -H -D zotonic \
&& chown -R zotonic /opt/zotonic/priv

# Use dumb-init to reap zombies, catch signals, and all the other stuff pid 1 should do.
ENTRYPOINT ["/usr/bin/dumb-init", "-c", "--", "/opt/zotonic/docker/docker-entrypoint.sh"]

CMD ["start-nodaemon"]

EXPOSE 8000 8443

9 changes: 3 additions & 6 deletions docker/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,11 @@ if [ -x "/opt/zotonic/src/scripts/zotonic-$1" ]; then
# Create the pid file and enable zotonic to write to it
touch /run/zotonic.pid && chown zotonic /run/zotonic.pid

# Generate the config file
sed -e s/%%GENERATED%%/${ZOTONIC_PASSWORD-changeme}/ \
-e s,%%USER_SITES_DIR%%,/opt/zotonic/user/sites, \
-e s,%%USER_MODULES_DIR%%,/opt/zotonic/user/modules, \
-e s,%%USER_EBIN_DIR%%,/opt/zotonic/user/ebin, /opt/zotonic/priv/zotonic.config.in > /etc/zotonic/zotonic.config
# Insert password from environment variable into zotonic.config
sed -i -e "s/{password, \"\"}/{password, \"${ZOTONIC_PASSWORD}\"}/" \
/etc/zotonic/zotonic.config

exec /usr/bin/gosu zotonic /opt/zotonic/bin/zotonic "$@"
else
exec "$@"
fi

9 changes: 9 additions & 0 deletions docker/zotonic.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[{zotonic,
[
{dbhost, "postgres"},
{password, ""},
{user_modules_dir, "/opt/zotonic/user/modules"},
{user_sites_dir, "/opt/zotonic/user/sites"},
{user_ebin_dir, "/opt/zotonic/user/ebin"}
]
}].

0 comments on commit e9fae70

Please sign in to comment.