Skip to content
Merged
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
4 changes: 2 additions & 2 deletions nginx-transcoder/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ if [ "$SSL_ENABLED" = true ] ; then



rm -rf /opt/data && mkdir -p /opt/data/dash && chown nginx /opt/data/dash && chmod 777 /opt/data/dash && mkdir -p /www && \
mkdir -p /opt/data/dash && find /opt/data/dash -mindepth 1 -delete && chown nginx /opt/data/dash && chmod 777 /opt/data/dash && mkdir -p /www && \

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mormegil6 can you check this plz?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@roddylindsay checked - the review comment is incorrect. Alpine 3.11's BusyBox find does support both -mindepth and -delete, so the entrypoint starts fine.

Verified against the exact runtime base image in this repo's Dockerfile (FROM alpine:3.11):

$ docker run --rm alpine:3.11 sh -c '
    cat /etc/alpine-release
    busybox | head -1
    mkdir -p /opt/data/dash/sub
    touch /opt/data/dash/a.m4s /opt/data/dash/sub/b.webm
    find /opt/data/dash -mindepth 1 -delete; echo "exit=$?"
    echo "remaining: $(ls -A /opt/data/dash | wc -l)"'
3.11.13
BusyBox v1.31.1 () multi-call binary.
exit=0
remaining: 0

busybox find --help on that image lists -mindepth, -maxdepth, -delete and -name. BusyBox has had FEATURE_FIND_DELETE long before 1.31, and Alpine enables it.

Worth noting the nested sub/b.webm in that test: it is removed along with its parent directory, which confirms -delete is doing the depth-first removal you would want here rather than failing on non-empty directories.

The mount point itself survives, which is the whole point of the change - rm -rf /opt/data on a bind mount or named volume either fails or blows away the mount's contents from underneath the host, whereas this resets only the segment output state.

Happy to swap in a rm -rf /opt/data/dash/* glob instead if you would rather not depend on find semantics at all, but it needs .[!.]* too to catch dotfiles, and it does not fail cleanly on an empty directory - so find reads better here.

One thing you may want regardless: as written the find sits inside an && chain, so any future failure would take the container down at startup. If you would prefer it to be non-fatal:

mkdir -p /opt/data/dash && { find /opt/data/dash -mindepth 1 -delete || true; } && chown nginx /opt/data/dash && ...

Your call - on Alpine 3.11 it does not fail, so this is just insurance against the base image changing later.

envsubst "$(env | sed -e 's/=.*//' -e 's/^/\$/g')" < \
/etc/nginx/nginx.conf.template > /etc/nginx/nginx.conf
### Send certbot Emission/Renewal to background
Expand All @@ -48,7 +48,7 @@ if [ "$SSL_ENABLED" = true ] ; then

else
echo "Running Earshot without SSL (connections will be insecure)"
rm -rf /opt/data && mkdir -p /opt/data/dash && chown nginx /opt/data/dash && chmod 777 /opt/data/dash && mkdir -p /www && \
mkdir -p /opt/data/dash && find /opt/data/dash -mindepth 1 -delete && chown nginx /opt/data/dash && chmod 777 /opt/data/dash && mkdir -p /www && \
envsubst "$(env | sed -e 's/=.*//' -e 's/^/\$/g')" < \
/etc/nginx/nginx-no-ssl.conf.template > /etc/nginx/nginx.conf
fi
Expand Down
Loading