Dockerfile 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. ARG GOVERSION=latest
  2. #
  3. # Maybe build Syncthing. This is a bit ugly as we can't make an entire
  4. # section of the Dockerfile conditional, so we end up always pulling the
  5. # golang image as builder. Then we check if the executable we need already
  6. # exists (pre-built) otherwise we build it.
  7. #
  8. FROM golang:$GOVERSION AS builder
  9. ARG BUILD_USER
  10. ARG BUILD_HOST
  11. ARG TARGETARCH
  12. WORKDIR /src
  13. COPY . .
  14. ENV CGO_ENABLED=0
  15. RUN echo syncthing-linux-$TARGETARCH
  16. RUN if [ ! -f syncthing-linux-$TARGETARCH ] ; then \
  17. go run build.go -no-upgrade build syncthing ; \
  18. mv syncthing syncthing-linux-$TARGETARCH ; \
  19. fi
  20. #
  21. # The rest of the Dockerfile uses the binary from the builder, prebuilt or
  22. # not.
  23. #
  24. FROM alpine
  25. ARG TARGETARCH
  26. EXPOSE 8384 22000/tcp 22000/udp 21027/udp
  27. VOLUME ["/var/syncthing"]
  28. RUN apk add --no-cache ca-certificates curl libcap su-exec tzdata
  29. COPY --from=builder /src/syncthing-linux-$TARGETARCH /bin/syncthing
  30. COPY --from=builder /src/script/docker-entrypoint.sh /bin/entrypoint.sh
  31. ENV PUID=1000 PGID=1000 HOME=/var/syncthing
  32. HEALTHCHECK --interval=1m --timeout=10s \
  33. CMD curl -fkLsS -m 2 127.0.0.1:8384/rest/noauth/health | grep -o --color=never OK || exit 1
  34. ENV STGUIADDRESS=0.0.0.0:8384
  35. RUN chmod 755 /bin/entrypoint.sh
  36. ENTRYPOINT ["/bin/entrypoint.sh", "/bin/syncthing", "-home", "/var/syncthing/config"]