Skip to content

Commit

Permalink
Add Dropbox filesystem fix
Browse files Browse the repository at this point in the history
  • Loading branch information
otherguy committed Jan 2, 2020
1 parent f22d316 commit 3f416e9
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 19 deletions.
16 changes: 12 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ ENV DEBIAN_FRONTEND noninteractive

# Install prerequisites
RUN apt-get update \
&& apt-get install -y --no-install-recommends apt-transport-https ca-certificates curl gnupg2 software-properties-common gosu locales locales-all
&& apt-get install -y --no-install-recommends apt-transport-https ca-certificates curl gnupg2 software-properties-common gosu locales locales-all unzip build-essential

# Create user and group
RUN mkdir -p /opt/dropbox /opt/dropbox/.dropbox /opt/dropbox/Dropbox \
Expand All @@ -43,12 +43,20 @@ WORKDIR /opt/dropbox/Dropbox
EXPOSE 17500

# https://help.dropbox.com/installs-integrations/desktop/linux-repository
RUN add-apt-repository 'deb http://linux.dropbox.com/debian buster main' \
&& apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 1C61A2656FB57B7E4DE0F4C1FC918B335044912E \
RUN apt-key adv --keyserver keyserver.ubuntu.com --recv-keys FC918B335044912E \
&& add-apt-repository 'deb http://linux.dropbox.com/debian buster main' \
&& apt-get update \
&& apt-get install -y --no-install-recommends libatomic1 python3-gpg dropbox \
&& rm -rf /var/lib/apt/lists/*

RUN curl --location https://github.com/dark/dropbox-filesystem-fix/archive/master.zip > /tmp/dropbox-filesystem-fix.zip \
&& unzip /tmp/dropbox-filesystem-fix.zip -d /opt \
&& rm /tmp/dropbox-filesystem-fix.zip \
&& mv /opt/dropbox-filesystem-fix-master/ /opt/dropbox-filesystem-fix/ \
&& cd /opt/dropbox-filesystem-fix/ \
&& make \
&& chmod +x /opt/dropbox-filesystem-fix/dropbox_start.py

# Dropbox insists on downloading its binaries itself via 'dropbox start -i'
RUN echo "y" | gosu dropbox dropbox start -i

Expand All @@ -72,4 +80,4 @@ COPY docker-entrypoint.sh /

# Set entrypoint and command
ENTRYPOINT ["/docker-entrypoint.sh"]
CMD ["/opt/dropbox/bin/dropboxd"]
CMD ["/opt/dropbox-filesystem-fix/dropbox_start.py"]
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,13 @@ The actual Dropbox folder, containing all your synced files.
Account and other settings for Dropbox. If you don't mount this folder, your account needs to be linked
every time you restart the container.

## Note 📝

It appears that as of `December 2019`, Dropbox (version `87.4.138`) is now finally enforcing its
[file system requirements](https://help.dropbox.com/installs-integrations/desktop/system-requirements#linux).
Because this causes problems with Docker volume mounts, this container now includes the
[`dropbox-filesystem-fix` patch](https://github.com/dark/dropbox-filesystem-fix/).

## Inspiration 💅

Originally forked from [`janeczku/dropbox`](https://hub.docker.com/r/janeczku/dropbox/). Thank you
Expand Down
47 changes: 32 additions & 15 deletions docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ if [ -z "${DROPBOX_GID}" ]; then
echo "DROPBOX_GID not specified, defaulting to dropbox user group id (${DROPBOX_GID})"
fi

# Set Max Workers for fsnotify
if [ -n "${MAX_USER_WATCHES}" ]; then
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.
if [ -z "$(grep ":${DROPBOX_GID}:" /etc/group)" ]; then
usermod -g users dropbox
Expand Down Expand Up @@ -53,17 +59,16 @@ if [[ -z "$DROPBOX_SKIP_UPDATE" ]]; then
echo "Latest :" $Latest
echo "Installed:" $Current
if [ ! -z "${Latest}" ] && [ ! -z "${Current}" ] && [ $Current != $Latest ]; then
echo "Downloading Dropbox $Latest..."
tmpdir=`mktemp -d`
curl -# -L $DL | tar xzf - -C $tmpdir
echo "Installing new version..."
rm -rf /opt/dropbox/bin/*
mv $tmpdir/.dropbox-dist/* /opt/dropbox/bin/
rm -rf $tmpdir
find /opt/dropbox/bin -type f -name "*.so" -exec chmod a+rx {} \;
find /opt/dropbox/bin -type f -name "*.so" -exec chown dropbox {} \;

echo "Dropbox updated to v$Latest"
echo "Downloading Dropbox $Latest..."
tmpdir=`mktemp -d`
curl -# -L $DL | tar xzf - -C $tmpdir
echo "Installing new version..."
rm -rf /opt/dropbox/bin/*
mv $tmpdir/.dropbox-dist/* /opt/dropbox/bin/
rm -rf $tmpdir
find /opt/dropbox/bin -type f -name "*.so" -exec chmod a+rx {} \;
find /opt/dropbox/bin -type f -name "*.so" -exec chown dropbox {} \;
echo "Dropbox updated to v$Latest"
else
echo "Dropbox is up-to-date"
fi
Expand All @@ -72,8 +77,20 @@ fi
echo ""
umask 002

echo "Patching dropbox_start.py for updated dropboxd path"
sed -i "s:~/.dropbox-dist/dropboxd:/opt/dropbox/bin/dropboxd:g" /opt/dropbox-filesystem-fix/dropbox_start.py
sed -i "s:/usr/bin/python:$(which python3):g" /opt/dropbox-filesystem-fix/dropbox_start.py

echo ""

echo "Starting dropboxd ($(cat /opt/dropbox/bin/VERSION))..."
exec gosu dropbox "$@" &
pid="$!"
trap "kill -SIGQUIT $pid" INT
wait
gosu dropbox /opt/dropbox-filesystem-fix/dropbox_start.py
export DROPBOX_PID=$(pidof dropbox)
trap "kill -SIGQUIT ${DROPBOX_PID}" INT

# Dropbox likes to restart itself. In that case, the container will exit!
while kill -0 ${DROPBOX_PID} 2> /dev/null; do
gosu dropbox dropbox status
sleep 1
done

0 comments on commit 3f416e9

Please sign in to comment.