Dockerfile 1.7 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. WORKDIR /src
  13. COPY . .
  14. ENV CGO_ENABLED=0
  15. RUN if [ ! -f syncthing-linux-$TARGETARCH ] ; then \
  16. go run build.go -no-upgrade build syncthing ; \
  17. mv syncthing syncthing-linux-$TARGETARCH ; \
  18. fi
  19. #
  20. # The rest of the Dockerfile uses the binary from the builder, prebuilt or
  21. # not.
  22. #
  23. FROM alpine
  24. ARG TARGETARCH
  25. LABEL org.opencontainers.image.authors="The Syncthing Project" \
  26. org.opencontainers.image.url="https://syncthing.net" \
  27. org.opencontainers.image.documentation="https://docs.syncthing.net" \
  28. org.opencontainers.image.source="https://github.com/syncthing/syncthing" \
  29. org.opencontainers.image.vendor="The Syncthing Project" \
  30. org.opencontainers.image.licenses="MPL-2.0" \
  31. org.opencontainers.image.title="Syncthing"
  32. EXPOSE 8384 22000/tcp 22000/udp 21027/udp
  33. VOLUME ["/var/syncthing"]
  34. RUN apk add --no-cache ca-certificates curl libcap su-exec tzdata
  35. COPY --from=builder /src/syncthing-linux-$TARGETARCH /bin/syncthing
  36. COPY --from=builder /src/script/docker-entrypoint.sh /bin/entrypoint.sh
  37. ENV PUID=1000 PGID=1000 HOME=/var/syncthing
  38. HEALTHCHECK --interval=1m --timeout=10s \
  39. CMD curl -fkLsS -m 2 127.0.0.1:8384/rest/noauth/health | grep -o --color=never OK || exit 1
  40. ENV STGUIADDRESS=0.0.0.0:8384
  41. ENV STHOMEDIR=/var/syncthing/config
  42. RUN chmod 755 /bin/entrypoint.sh
  43. ENTRYPOINT ["/bin/entrypoint.sh", "/bin/syncthing"]