diff --git a/syncthing/Dockerfile b/syncthing/Dockerfile new file mode 100644 index 0000000..24c7747 --- /dev/null +++ b/syncthing/Dockerfile @@ -0,0 +1,33 @@ +FROM debian:jessie + +ENV SYNCTHING_VERSION 0.10.30 + +RUN apt-get update && apt-get install -y ca-certificates --no-install-recommends && rm -rf /var/lib/apt/lists/* + +# gpg: key 00654A3E: public key "Syncthing Release Management " imported +RUN gpg --keyserver pool.sks-keyservers.net --recv-keys 37C84554E7E0A261E4F76E1ED26E6ED000654A3E + +RUN set -x \ + && apt-get update \ + && apt-get install -y curl xmlstarlet --no-install-recommends \ + && rm -rf /var/lib/apt/lists/* \ + && tarball="syncthing-linux-amd64-v${SYNCTHING_VERSION}.tar.gz" \ + && curl -SL "https://github.com/syncthing/syncthing/releases/download/v${SYNCTHING_VERSION}/"{"$tarball",sha1sum.txt.asc} -O \ + && apt-get purge -y --auto-remove curl \ + && gpg --verify sha1sum.txt.asc \ + && grep -E " ${tarball}\$" sha1sum.txt.asc | sha1sum -c - \ + && rm sha1sum.txt.asc \ + && tar -xvf "$tarball" --strip-components=1 "$(basename "$tarball" .tar.gz)"/syncthing \ + && mv syncthing /usr/local/bin/syncthing \ + && rm "$tarball" + +EXPOSE 8080 22000 21025/udp + +ADD entrypoint.sh /entrypoint.sh + +RUN useradd -m syncthing +VOLUME /home/syncthing +WORKDIR /home/syncthing + +ENTRYPOINT ["/entrypoint.sh"] +CMD ["syncthing"] diff --git a/syncthing/entrypoint.sh b/syncthing/entrypoint.sh new file mode 100755 index 0000000..4359472 --- /dev/null +++ b/syncthing/entrypoint.sh @@ -0,0 +1,15 @@ +#!/bin/bash +set -e + +HOME=`eval echo ~syncthing` +CONFIG_FOLDER="$HOME/.config/syncthing" +CONFIG_FILE="$CONFIG_FOLDER/config.xml" + +if [ ! -f "$CONFIG_FILE" ]; then + syncthing -generate="$CONFIG_FOLDER" + xmlstarlet ed -L -u "/configuration/gui/address" -v "0.0.0.0:8080" "$CONFIG_FILE" +fi + +chown -R syncthing:syncthing "$HOME" + +exec su - syncthing -c syncthing