Skip to content

Commit

Permalink
feat(container): config in-container host,port and configfile by env (#…
Browse files Browse the repository at this point in the history
…47)

* feat(container): config in-container host,port and configfile by environment variables && improve entrypoint.sh

* feat(container): ENTRYPOINT down to CMD for simplify entrypoint.sh  && delete env DEBUG for conflict with exec
  • Loading branch information
bonjour-py committed Jun 14, 2024
1 parent 31a08bb commit 3fbbd1e
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 7 deletions.
5 changes: 2 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ ARG ENV
ENV TZ="Asia/Shanghai"
ENV UID=1000
ENV GID=1000
ENV DEBUG="false"
ENV WEBDAV_LOGGING_LEVEL="INFO"

RUN if [ "$ENV" = "rex" ]; then echo "Change depends" \
Expand All @@ -29,7 +28,7 @@ RUN \
# LDAP client's depends ---
&& apk add --no-cache libsasl libldap \
# create non-root user ---
&& apk add --no-cache shadow \
&& apk add --no-cache shadow su-exec\
&& addgroup -S -g $GID runner \
&& adduser -S -D -G runner -u $UID -s /bin/sh runner \
# support timezone ---
Expand All @@ -45,7 +44,7 @@ WORKDIR /app
VOLUME /data
EXPOSE 8000

ENTRYPOINT /app/entrypoint.sh
CMD [ "/app/entrypoint.sh" ]

LABEL org.opencontainers.image.title="ASGI WebDAV Server"
LABEL org.opencontainers.image.authors="Rex Zhang"
Expand Down
22 changes: 18 additions & 4 deletions docker/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,22 @@ User gid: $(id -g runner)
echo "prepare..."
chown -R runner:runner /data

# run server
su runner -c "python -m asgi_webdav -H 0.0.0.0 -c /data/webdav.json --logging-no-display-datetime --logging-no-use-colors"
if [ -z "$WEBDAV_HOST" ]; then
WEBDAV_HOST="0.0.0.0"
fi

# for dev
if [ "$DEBUG" = "true" ]; then python; fi
if [ -z "$WEBDAV_PORT" ]; then
WEBDAV_PORT="8000"
fi

if [ -z "$WEBDAV_CONFIGFILE" ]; then
WEBDAV_CONFIGFILE="/data/webdav.json"
fi

exec su-exec runner \
python -m asgi_webdav \
--host "$WEBDAV_HOST" \
--port "$WEBDAV_PORT" \
--config "$WEBDAV_CONFIGFILE" \
--logging-no-display-datetime \
--logging-no-use-colors

0 comments on commit 3fbbd1e

Please sign in to comment.