Add tini, rename entry point, and allow running sh directly

master
Alexey Sokolov 7 years ago
parent 3ca5fb9d34
commit 79f85cc94c

@ -2,7 +2,7 @@
# Build modules from source.
if [ -d "${DATADIR}/modules" ]; then
cd "${DATADIR}/modules" || exit 1
cd "${DATADIR}/modules" || exit 11
# Find module sources.
modules=$(find . -name "*.cpp")
@ -10,7 +10,7 @@ if [ -d "${DATADIR}/modules" ]; then
if [ -n "$modules" ]; then
# Build modules.
echo "Building modules $modules..."
/opt/znc/bin/znc-buildmod $modules || exit 1
/opt/znc/bin/znc-buildmod $modules || exit 12
fi
fi

@ -14,6 +14,7 @@ RUN set -x \
&& adduser -S znc \
&& addgroup -S znc \
&& apk add --no-cache --virtual runtime-dependencies \
tini \
icu \
openssl \
cyrus-sasl \
@ -41,11 +42,11 @@ RUN set -x \
&& apk del build-dependencies \
&& cd / && rm -Rf /znc-src
COPY znc-entrypoint.sh /
COPY docker-entrypoint.sh /
USER znc
VOLUME /znc-data
EXPOSE 6667
ENTRYPOINT ["/znc-entrypoint.sh"]
ENTRYPOINT ["/docker-entrypoint.sh"]

@ -0,0 +1,26 @@
#!/bin/sh
# "docker run -ti znc sh" should work, according to
# https://github.com/docker-library/official-images
if [ "${1:0:1}" != '-' ]; then
exec "$@"
fi
# Options.
DATADIR="/znc-data"
# Make sure $DATADIR is owned by znc user. This effects ownership of the
# mounted directory on the host machine too.
chown -R znc:znc "$DATADIR" || exit 1
chmod 700 "$DATADIR" || exit 2
# This file is added by znc:full image
if [ -r /znc-build-modules.sh ]; then
source /znc-build-modules.sh || exit 3
fi
cd /
# ZNC itself responds to SIGTERM, and reaps its children, but whatever was
# started via *shell module is not guaranteed to reap their children.
exec /sbin/tini -- /opt/znc/bin/znc --foreground --datadir "$DATADIR" "$@"

@ -1,16 +0,0 @@
#!/bin/sh
# Options.
export DATADIR="/znc-data"
# Make sure $DATADIR is owned by znc user. This effects ownership of the
# mounted directory on the host machine too.
chown -R znc:znc "$DATADIR" || exit 1
chmod 700 "$DATADIR" || exit 2
# Added by znc:full image
if [ -r /znc-build-modules.sh ]; then
/znc-build-modules.sh || exit 3
fi
exec /opt/znc/bin/znc --foreground --datadir /znc-data "$@"
Loading…
Cancel
Save