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 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. EXPOSE 8384 22000/tcp 22000/udp 21027/udp
  26. VOLUME ["/var/syncthing"]
  27. RUN apk add --no-cache ca-certificates curl libcap su-exec tzdata
  28. COPY --from=builder /src/syncthing-linux-$TARGETARCH /bin/syncthing
  29. COPY --from=builder /src/script/docker-entrypoint.sh /bin/entrypoint.sh
  30. ENV PUID=1000 PGID=1000 HOME=/var/syncthing
  31. HEALTHCHECK --interval=1m --timeout=10s \
  32. CMD curl -fkLsS -m 2 127.0.0.1:8384/rest/noauth/health | grep -o --color=never OK || exit 1
  33. ENV STGUIADDRESS=0.0.0.0:8384
  34. ENV STHOMEDIR=/var/syncthing/config
  35. RUN chmod 755 /bin/entrypoint.sh
  36. ENTRYPOINT ["/bin/entrypoint.sh", "/bin/syncthing"]