Skip to content

Commit

Permalink
feat(container): ENTRYPOINT down to CMD for simplify entrypoint.sh &&…
Browse files Browse the repository at this point in the history
… delete env DEBUG for conflict with exec
  • Loading branch information
bonjour-py authored Jun 14, 2024
1 parent fe91a08 commit bfb313e
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 41 deletions.
4 changes: 1 addition & 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 Down Expand Up @@ -45,8 +44,7 @@ WORKDIR /app
VOLUME /data
EXPOSE 8000

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

LABEL org.opencontainers.image.title="ASGI WebDAV Server"
LABEL org.opencontainers.image.authors="Rex Zhang"
Expand Down
67 changes: 29 additions & 38 deletions docker/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,44 +1,35 @@
#!/bin/sh

# for dev
if [ "$DEBUG" = "true" ]; then exec python; fi

if [ "$1" == "asgi_webdav" ]; then

## set non-root user
usermod -o -u "$UID" runner
groupmod -o -g "$GID" runner

echo "
------------------------
User uid: $(id -u runner)
User gid: $(id -g runner)
------------------------
"

echo "prepare..."
chown -R runner:runner /data

if [ -z "$WEBDAV_HOST" ]; then
WEBDAV_HOST="0.0.0.0"
fi

if [ -z "$WEBDAV_PORT" ]; then
WEBDAV_PORT="8000"
fi

if [ -z "$WEBDAV_CONFIGFILE" ]; then
WEBDAV_CONFIGFILE="/data/webdav.json"
fi
## set non-root user
usermod -o -u "$UID" runner
groupmod -o -g "$GID" runner

echo "
------------------------
User uid: $(id -u runner)
User gid: $(id -g runner)
------------------------
"

echo "prepare..."
chown -R runner:runner /data

if [ -z "$WEBDAV_HOST" ]; then
WEBDAV_HOST="0.0.0.0"
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
if [ -z "$WEBDAV_PORT" ]; then
WEBDAV_PORT="8000"
fi

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

exec $*
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 bfb313e

Please sign in to comment.