Dockerfile 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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. ADD https://github.com/syncthing/syncthing/archive/refs/heads/main.zip /tmp/
  13. RUN apt-get update && apt-get install unzip git -y && unzip /tmp/main.zip -d /tmp && mv /tmp/syncthing-main /src
  14. WORKDIR /src
  15. ENV CGO_ENABLED=0
  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. LABEL org.opencontainers.image.authors="The Syncthing Project" \
  27. org.opencontainers.image.url="https://syncthing.net" \
  28. org.opencontainers.image.documentation="https://docs.syncthing.net" \
  29. org.opencontainers.image.source="https://github.com/syncthing/syncthing" \
  30. org.opencontainers.image.vendor="The Syncthing Project" \
  31. org.opencontainers.image.licenses="MPL-2.0" \
  32. org.opencontainers.image.title="Syncthing"
  33. EXPOSE 8384 22000/tcp 22000/udp 21027/udp
  34. VOLUME ["/var/syncthing"]
  35. RUN apk add --no-cache ca-certificates curl libcap su-exec tzdata
  36. COPY --from=builder /src/syncthing-linux-$TARGETARCH /bin/syncthing
  37. COPY --from=builder /src/script/docker-entrypoint.sh /bin/entrypoint.sh
  38. ENV PUID=1000 PGID=1000 HOME=/var/syncthing
  39. HEALTHCHECK --interval=1m --timeout=10s \
  40. CMD curl -fkLsS -m 2 127.0.0.1:8384/rest/noauth/health | grep -o --color=never OK || exit 1
  41. ENV STGUIADDRESS=0.0.0.0:8384
  42. ENV STHOMEDIR=/var/syncthing/config
  43. RUN chmod 755 /bin/entrypoint.sh
  44. ENTRYPOINT ["/bin/entrypoint.sh", "/bin/syncthing"]