Skip to content

Commit

Permalink
Make the polling delay configurable (#19)
Browse files Browse the repository at this point in the history
  • Loading branch information
otherguy authored Feb 15, 2021
1 parent d1b0e26 commit 26143db
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 24 deletions.
49 changes: 26 additions & 23 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,21 @@ FROM debian:buster
# Maintainer
LABEL maintainer "Alexander Graf <alex@otherguy.io>"

# Build arguments
ARG VCS_REF=master
ARG BUILD_DATE=""

# http://label-schema.org/rc1/
LABEL org.label-schema.schema-version "1.0"
LABEL org.label-schema.name "Dropbox"
LABEL org.label-schema.build-date "${BUILD_DATE}"
LABEL org.label-schema.description "Standalone Dropbox client"
LABEL org.label-schema.vcs-url "https://github.com/otherguy/docker-dropbox"
LABEL org.label-schema.vcs-ref "${VCS_REF}"

# Required to prevent warnings
ARG DEBIAN_FRONTEND=noninteractive
ARG DEBCONF_NONINTERACTIVE_SEEN=true

# Change working directory
WORKDIR /opt/dropbox/Dropbox

# Not really required for --net=host
EXPOSE 17500

# Set language
ENV LANG "en_US.UTF-8"
ENV LANGUAGE "en_US.UTF-8"
ENV LC_ALL "en_US.UTF-8"

# Install prerequisites
RUN apt-get update \
&& apt-get install -y --no-install-recommends apt-transport-https ca-certificates curl gnupg2 \
Expand All @@ -33,21 +32,10 @@ RUN mkdir -p /opt/dropbox /opt/dropbox/.dropbox /opt/dropbox/Dropbox \
&& useradd --home-dir /opt/dropbox --comment "Dropbox Daemon Account" --user-group --shell /usr/sbin/nologin dropbox \
&& chown -R dropbox:dropbox /opt/dropbox

# Set language
ENV LANG "en_US.UTF-8"
ENV LANGUAGE "en_US.UTF-8"
ENV LC_ALL "en_US.UTF-8"

# Generate locales
RUN sed --in-place '/en_US.UTF-8/s/^# //' /etc/locale.gen \
&& locale-gen

# Change working directory
WORKDIR /opt/dropbox/Dropbox

# Not really required for --net=host
EXPOSE 17500

# https://help.dropbox.com/installs-integrations/desktop/linux-repository
RUN apt-key adv --keyserver keyserver.ubuntu.com --recv-keys FC918B335044912E \
&& add-apt-repository 'deb http://linux.dropbox.com/debian buster main' \
Expand All @@ -74,6 +62,21 @@ RUN mkdir -p /opt/dropbox/bin/ /tmp \
# Create volumes
VOLUME ["/opt/dropbox/.dropbox", "/opt/dropbox/Dropbox"]

# Build arguments
ARG VCS_REF=master
ARG BUILD_DATE=""

# http://label-schema.org/rc1/
LABEL org.label-schema.schema-version "1.0"
LABEL org.label-schema.name "Dropbox"
LABEL org.label-schema.build-date "${BUILD_DATE}"
LABEL org.label-schema.description "Standalone Dropbox client"
LABEL org.label-schema.vcs-url "https://github.com/otherguy/docker-dropbox"
LABEL org.label-schema.vcs-ref "${VCS_REF}"

# Configurable sleep delay
ENV SLEEP_DELAY=5

# Install init script and dropbox command line wrapper
COPY docker-entrypoint.sh /

Expand Down
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,11 @@ files. Defaults to `1000`.
If set to `true`, skips updating the Dropbox app on container startup. _Note:_ This is not very reliable
because the Dropbox daemon will still try to update itself even if this is set to `true`.

- `SLEEP_DELAY`
Needs to be set to a positive integer value. The Dropbox daemon is polled for its status at regular intervals,
which can be configured to reduce load on the system. This is the number in seconds to wait between polling the
Dropbox daemon. Defaults to `5`.

### Exposed Volumes

- `/opt/dropbox/Dropbox`
Expand Down
7 changes: 6 additions & 1 deletion docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ if [ -z "$(grep ":${DROPBOX_GID}:" /etc/group)" ]; then
groupadd -g $DROPBOX_GID dropbox
fi

if [[ ! "${SLEEP_DELAY}" =~ ^[0-9]+$ ]]; then
echo "SLEEP_DELAY not set to a valid number, defaulting to 5!"
export SLEEP_DELAY=5
fi

# Set dropbox account's UID/GID.
usermod -u ${DROPBOX_UID} -g ${DROPBOX_GID} --non-unique dropbox > /dev/null 2>&1

Expand Down Expand Up @@ -101,5 +106,5 @@ sleep 5
while kill -0 ${DROPBOX_PID} 2> /dev/null; do
[ -d "/proc/${DROPBOX_PID}" ] && [ -f "/opt/dropbox/.dropbox/info.json" ] && gosu dropbox dropbox status
/usr/bin/find /tmp -maxdepth 1 -type d -mtime +1 -exec rm -rf {} \;
/bin/sleep 1
/bin/sleep ${SLEEP_DELAY}
done

0 comments on commit 26143db

Please sign in to comment.