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

Added a setting for fsnotify watchers and correct install issue for dockerfile #28

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
45 changes: 9 additions & 36 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,45 +2,18 @@ FROM debian:jessie
MAINTAINER Jan Broer <[email protected]>
ENV DEBIAN_FRONTEND noninteractive

# Following 'How do I add or remove Dropbox from my Linux repository?' - https://www.dropbox.com/en/help/246
RUN echo 'deb http://linux.dropbox.com/debian jessie main' > /etc/apt/sources.list.d/dropbox.list \
&& apt-key adv --keyserver pgp.mit.edu --recv-keys 1C61A2656FB57B7E4DE0F4C1FC918B335044912E \
&& apt-get -qqy update \
# Note 'ca-certificates' dependency is required for 'dropbox start -i' to succeed
&& apt-get -qqy install ca-certificates curl python-gpgme dropbox \
# Perform image clean up.
&& apt-get -qqy autoclean \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* \
# Create service account and set permissions.
# Following https://www.dropbox.com/install?os=lnx
RUN apt-get update; apt-get install -y curl python \
&& tmpdir=`mktemp -d` \
&& curl -# -L https://www.dropbox.com/download?plat=lnx.x86_64 | tar xzf - -C $tmpdir \
&& mkdir /opt/dropbox \
&& mv $tmpdir/.dropbox-dist/* /opt/dropbox/ \
&& rm -rf $tmpdir \
&& curl -L https://www.dropbox.com/download?dl=packages/dropbox.py > /usr/bin/dropbox-cli \
&& chmod +x /usr/bin/dropbox-cli \
&& groupadd dropbox \
&& useradd -m -d /dbox -c "Dropbox Daemon Account" -s /usr/sbin/nologin -g dropbox dropbox

# Dropbox is weird: it insists on downloading its binaries itself via 'dropbox
# start -i'. So we switch to 'dropbox' user temporarily and let it do its thing.
USER dropbox
RUN mkdir -p /dbox/.dropbox /dbox/.dropbox-dist /dbox/Dropbox /dbox/base \
&& echo y | dropbox start -i

# Switch back to root, since the run script needs root privs to chmod to the user's preferrred UID
USER root

# Dropbox has the nasty tendency to update itself without asking. In the processs it fills the
# file system over time with rather large files written to /dbox and /tmp. The auto-update routine
# also tries to restart the dockerd process (PID 1) which causes the container to be terminated.
RUN mkdir -p /opt/dropbox \
# Prevent dropbox to overwrite its binary
&& mv /dbox/.dropbox-dist/dropbox-lnx* /opt/dropbox/ \
&& mv /dbox/.dropbox-dist/dropboxd /opt/dropbox/ \
&& mv /dbox/.dropbox-dist/VERSION /opt/dropbox/ \
&& rm -rf /dbox/.dropbox-dist \
&& install -dm0 /dbox/.dropbox-dist \
# Prevent dropbox to write update files
&& chmod u-w /dbox \
&& chmod o-w /tmp \
&& chmod g-w /tmp \
# Prepare for command line wrapper
&& mv /usr/bin/dropbox /usr/bin/dropbox-cli

# Install init script and dropbox command line wrapper
COPY run /root/
COPY dropbox /usr/bin/dropbox
Expand Down
8 changes: 8 additions & 0 deletions run
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,14 @@ if [ -z "$DBOX_GID" ]; then
echo "DBOX_GID variable not specified, defaulting to dropbox user group id ($DBOX_GID)"
fi

# Set Max Workers for fsnotify
if [ -z "$MAX_USER_WATCHES" ]; then
echo "max_user_watchers left at default"
else
echo fs.inotify.max_user_watches=${MAX_USER_WATCHES} | tee -a /etc/sysctl.conf; sysctl -p
echo "Setting fs.inotify.max_user_watches to ${MAX_USER_WATCHES}"
fi

# Look for existing group, if not found create dropbox with specified GID.
FIND_GROUP=$(grep ":$DBOX_GID:" /etc/group)

Expand Down