From 6c766bcfef264cd0dc0cb5bc6836fb469a659f46 Mon Sep 17 00:00:00 2001 From: f Date: Tue, 10 Sep 2019 22:32:07 -0300 Subject: [PATCH] syncthing --- Dockerfile | 36 +++++++++++++++++++++++++++++++++++- monit.conf | 3 +++ syncthing_start.sh | 6 ++++++ syncthing_stop.sh | 3 +++ 4 files changed, 47 insertions(+), 1 deletion(-) create mode 100644 monit.conf create mode 100644 syncthing_start.sh create mode 100644 syncthing_stop.sh diff --git a/Dockerfile b/Dockerfile index 59c5898..aa3e844 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,2 +1,36 @@ -FROM sutty/monit:latest +FROM sutty/daemonize:latest AS build MAINTAINER "f " + +ARG VERSION=1.2.2 + +RUN wget https://github.com/syncthing/syncthing/releases/download/v${VERSION}/syncthing-linux-amd64-v${VERSION}.tar.gz +RUN tar x -Of syncthing-linux-amd64-v${VERSION}.tar.gz syncthing-linux-amd64-v${VERSION}/syncthing \ + > /usr/local/bin/syncthing +RUN chmod +x /usr/local/bin/syncthing +RUN strip --strip-all /usr/local/bin/syncthing + +COPY ./syncthing_stop.sh /usr/local/bin/syncthing_stop +COPY ./syncthing_start.sh /usr/local/bin/syncthing_start +RUN chmod 755 /usr/local/bin/syncthing_stop /usr/local/bin/syncthing_start + +RUN echo /home/builder/packages/home > /etc/apk/repositories +RUN apk add --no-cache daemonize + +FROM sutty/monit:latest + +COPY --from=build /usr/local/bin/syncthing /usr/local/bin/syncthing +COPY --from=build /usr/local/bin/syncthing_stop /usr/local/bin/syncthing_stop +COPY --from=build /usr/local/bin/syncthing_start /usr/local/bin/syncthing_start +COPY --from=build /usr/sbin/daemonize /usr/sbin/daemonize +COPY ./monit.conf /etc/monit.d/syncthing.conf + +RUN addgroup -S syncthing +RUN adduser -s /bin/sh -G syncthing -S -h /home/syncthing syncthing +RUN monit -t + +RUN apk add --no-cache ca-certificates + +EXPOSE 22000 +EXPOSE 22000/udp + +VOLUME /home/syncthing diff --git a/monit.conf b/monit.conf new file mode 100644 index 0000000..993cdc9 --- /dev/null +++ b/monit.conf @@ -0,0 +1,3 @@ +check process syncthing with pidfile /tmp/syncthing.pid + start program = "/usr/local/bin/syncthing_start" as uid "syncthing" + stop program = "/usr/local/bin/syncthing_stop" diff --git a/syncthing_start.sh b/syncthing_start.sh new file mode 100644 index 0000000..461c61e --- /dev/null +++ b/syncthing_start.sh @@ -0,0 +1,6 @@ +#!/bin/sh + +daemonize -p /tmp/syncthing.pid -l /tmp/syncthing.pid \ +/usr/local/bin/syncthing -no-browser \ + -logfile="/home/syncthing/syncthing.log" \ + -gui-address="http://0.0.0.0:8443" diff --git a/syncthing_stop.sh b/syncthing_stop.sh new file mode 100644 index 0000000..0e59585 --- /dev/null +++ b/syncthing_stop.sh @@ -0,0 +1,3 @@ +#!/bin/sh + +ps aux | grep syncthing | tr -s " " | cut -d " " -f 2 | xargs kill