Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(container): config in-container host,port and configfile by env #47

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading