Add a custom entrypoint: verify that data files are writable
This commit is contained in:
parent
038f166869
commit
64af9d2890
2 changed files with 27 additions and 1 deletions
|
@ -36,6 +36,11 @@ ARG BUILD_CONTRIB_MODULES
|
||||||
RUN apk add --no-cache openssl && (test -z "$BUILD_CONTRIB_MODULES" || apk add --no-cache libexecinfo)
|
RUN apk add --no-cache openssl && (test -z "$BUILD_CONTRIB_MODULES" || apk add --no-cache libexecinfo)
|
||||||
|
|
||||||
COPY --from=builder /atheme/ /atheme
|
COPY --from=builder /atheme/ /atheme
|
||||||
|
|
||||||
|
# Add custom entrypoint to check that data dir is writable - Atheme does not check this by itself
|
||||||
|
RUN echo "$ATHEME_UID" > /.atheme_uid
|
||||||
|
COPY entrypoint.sh /
|
||||||
|
|
||||||
RUN adduser -D -h /atheme -u $ATHEME_UID atheme
|
RUN adduser -D -h /atheme -u $ATHEME_UID atheme
|
||||||
RUN chown -R atheme /atheme
|
RUN chown -R atheme /atheme
|
||||||
USER atheme
|
USER atheme
|
||||||
|
@ -43,4 +48,4 @@ USER atheme
|
||||||
# Services config & DB
|
# Services config & DB
|
||||||
VOLUME /atheme/etc
|
VOLUME /atheme/etc
|
||||||
|
|
||||||
ENTRYPOINT ["/atheme/bin/atheme-services", "-n"]
|
ENTRYPOINT ["/entrypoint.sh"]
|
||||||
|
|
21
entrypoint.sh
Executable file
21
entrypoint.sh
Executable file
|
@ -0,0 +1,21 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
DATADIR=/atheme/etc
|
||||||
|
if ! test -w "$DATADIR/"; then
|
||||||
|
echo "ERROR: $DATADIR must be mounted to a directory writable by UID $(cat /.atheme_uid)"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
DBPATH="$DATADIR/services.db"
|
||||||
|
if test -f "$DBPATH" && ! test -r "$DBPATH"; then
|
||||||
|
echo "ERROR: $DBPATH must be readable by UID $(cat /.atheme_uid)"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
TMPPATH="$DATADIR/services.db.new"
|
||||||
|
if test -f "$TMPPATH" && ! test -w "$TMPPATH"; then
|
||||||
|
echo "ERROR: $TMPPATH must either not exist or be writable by UID $(cat /.atheme_uid)"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
/atheme/bin/atheme-services -n "$@"
|
Loading…
Reference in a new issue