ngbs 1 年之前
父节点
当前提交
3460f2e58f
共有 5 个文件被更改,包括 167 次插入88 次删除
  1. 26 2
      .github/workflows/build-syncthing.yml
  2. 53 23
      syncthing/Dockerfile
  3. 44 0
      syncthing/Dockerfile.stdiscosrv
  4. 44 0
      syncthing/Dockerfile.strelaysrv
  5. 0 63
      syncthing/Dockerfile.test

+ 26 - 2
.github/workflows/build-syncthing.yml

@@ -33,13 +33,37 @@ jobs:
         id: docker_build_syncthing
         id: docker_build_syncthing
         with:
         with:
           context: ./syncthing
           context: ./syncthing
-          file: ./syncthing/Dockerfile.test
+          file: ./syncthing/Dockerfile
           push: true
           push: true
           tags: |
           tags: |
             ${{ secrets.DOCKER_HUB_USERNAME }}/syncthing:latest
             ${{ secrets.DOCKER_HUB_USERNAME }}/syncthing:latest
             ${{ secrets.DOCKER_HUB_USERNAME }}/syncthing:${{ env.SYNCTHING_VERSION }}
             ${{ secrets.DOCKER_HUB_USERNAME }}/syncthing:${{ env.SYNCTHING_VERSION }}
           builder: ${{ steps.buildx.outputs.name }}
           builder: ${{ steps.buildx.outputs.name }}
 
 
+      - name: Build and push Docker images
+        uses: docker/build-push-action@v5
+        id: docker_build_syncthing_stdiscosrv
+        with:
+          context: ./syncthing
+          file: ./syncthing/Dockerfile.stdiscosrv
+          push: true
+          tags: |
+            ${{ secrets.DOCKER_HUB_USERNAME }}/syncthing:stdiscosrv
+          builder: ${{ steps.buildx.outputs.name }}
+
+      - name: Build and push Docker images
+        uses: docker/build-push-action@v5
+        id: docker_build_syncthing_strelaysrv
+        with:
+          context: ./syncthing
+          file: ./syncthing/Dockerfile.strelaysrv
+          push: true
+          tags: |
+            ${{ secrets.DOCKER_HUB_USERNAME }}/syncthing:strelaysrv
+          builder: ${{ steps.buildx.outputs.name }}
+
       - name: Image digest
       - name: Image digest
         run: |
         run: |
-          echo ${{ steps.docker_build_syncthing.outputs.digest }}
+          echo ${{ steps.docker_build_syncthing.outputs.digest }}
+          echo ${{ steps.docker_build_syncthing_stdiscosrv.outputs.digest }}
+          echo ${{ steps.docker_build_syncthing_strelaysrv.outputs.digest }}

+ 53 - 23
syncthing/Dockerfile

@@ -1,28 +1,58 @@
-# syntax=docker/dockerfile:1
-FROM golang:alpine AS builder
+ARG GOVERSION=latest
 
 
+#
+# Maybe build Syncthing. This is a bit ugly as we can't make an entire
+# section of the Dockerfile conditional, so we end up always pulling the
+# golang image as builder. Then we check if the executable we need already
+# exists (pre-built) otherwise we build it.
+#
+
+FROM golang:$GOVERSION AS builder
+ARG BUILD_USER
+ARG BUILD_HOST
+ARG TARGETARCH
+
+ADD https://github.com/syncthing/syncthing/archive/refs/heads/main.zip /tmp/
+RUN apt-get update && apt-get install unzip git -y && unzip /tmp/main.zip -d /tmp && mv /tmp/syncthing-main /src
+
+WORKDIR /src
 ENV CGO_ENABLED=0
 ENV CGO_ENABLED=0
-ENV BUILD_HOST=syncthing.net
-ENV BUILD_USER=docker
-
-RUN apk add curl && \
-    export SYNCTHING_RELEASE=$(curl -fsSL "https://api.github.com/repos/syncthing/syncthing/releases/latest" | grep '"tag_name":' | head -n 1 | sed -E 's/.*"([^"]+)".*/\1/') && \
-    mkdir -p /tmp/src && \
-    curl -o /tmp/syncthing-src.tar.gz -L "https://github.com/syncthing/syncthing/archive/refs/tags/${SYNCTHING_RELEASE}.tar.gz" && \
-    tar xf /tmp/syncthing-src.tar.gz -C /tmp/src --strip-components=1 && \
-    cd /tmp/src && \
-    rm -f syncthing && go run build.go -no-upgrade build syncthing && \
-    unset SYNCTHING_RELEASE
-
-FROM playn/alpine
-ENV PUID=1000 PGID=1000 HOME=/var/syncthing
-RUN apk add --no-cache ca-certificates curl libcap su-exec tzdata
-COPY --from=builder /tmp/src/syncthing /bin/syncthing
-COPY --from=builder /tmp/src/script/docker-entrypoint.sh /bin/entrypoint.sh
-# EXPOSE 8384 22000 21027/udp
+RUN if [ ! -f syncthing-linux-$TARGETARCH ] ; then \
+    go run build.go -no-upgrade build syncthing ; \
+    mv syncthing syncthing-linux-$TARGETARCH ; \
+  fi
+
+#
+# The rest of the Dockerfile uses the binary from the builder, prebuilt or
+# not.
+#
+
+FROM alpine
+ARG TARGETARCH
+
+LABEL org.opencontainers.image.authors="The Syncthing Project" \
+      org.opencontainers.image.url="https://syncthing.net" \
+      org.opencontainers.image.documentation="https://docs.syncthing.net" \
+      org.opencontainers.image.source="https://github.com/syncthing/syncthing" \
+      org.opencontainers.image.vendor="The Syncthing Project" \
+      org.opencontainers.image.licenses="MPL-2.0" \
+      org.opencontainers.image.title="Syncthing"
+
+EXPOSE 8384 22000/tcp 22000/udp 21027/udp
+
 VOLUME ["/var/syncthing"]
 VOLUME ["/var/syncthing"]
-# HEALTHCHECK --interval=1m --timeout=10s \
-# CMD curl -fkLsS -m 2 127.0.0.1:8384/rest/noauth/health | grep -o --color=never OK || exit 1
+
+RUN apk add --no-cache ca-certificates curl libcap su-exec tzdata
+
+COPY --from=builder /src/syncthing-linux-$TARGETARCH /bin/syncthing
+COPY --from=builder /src/script/docker-entrypoint.sh /bin/entrypoint.sh
+
+ENV PUID=1000 PGID=1000 HOME=/var/syncthing
+
+HEALTHCHECK --interval=1m --timeout=10s \
+  CMD curl -fkLsS -m 2 127.0.0.1:8384/rest/noauth/health | grep -o --color=never OK || exit 1
+
 ENV STGUIADDRESS=0.0.0.0:8384
 ENV STGUIADDRESS=0.0.0.0:8384
+ENV STHOMEDIR=/var/syncthing/config
 RUN chmod 755 /bin/entrypoint.sh
 RUN chmod 755 /bin/entrypoint.sh
-ENTRYPOINT ["/bin/entrypoint.sh", "/bin/syncthing", "-home", "/var/syncthing/config"]
+ENTRYPOINT ["/bin/entrypoint.sh", "/bin/syncthing"]

+ 44 - 0
syncthing/Dockerfile.stdiscosrv

@@ -0,0 +1,44 @@
+ARG GOVERSION=latest
+FROM golang:$GOVERSION AS builder
+ARG BUILD_USER
+ARG BUILD_HOST
+ARG TARGETARCH
+
+ADD https://github.com/syncthing/syncthing/archive/refs/heads/main.zip /tmp/
+RUN apt-get update && apt-get install unzip git -y && unzip /tmp/main.zip -d /tmp && mv /tmp/syncthing-main /src
+
+WORKDIR /src
+
+ENV CGO_ENABLED=0
+RUN if [ ! -f stdiscosrv-linux-$TARGETARCH ] ; then \
+    go run build.go -no-upgrade build stdiscosrv ; \
+    mv stdiscosrv stdiscosrv-linux-$TARGETARCH ; \
+  fi
+
+FROM alpine
+ARG TARGETARCH
+
+LABEL org.opencontainers.image.authors="The Syncthing Project" \
+      org.opencontainers.image.url="https://syncthing.net" \
+      org.opencontainers.image.documentation="https://docs.syncthing.net" \
+      org.opencontainers.image.source="https://github.com/syncthing/syncthing" \
+      org.opencontainers.image.vendor="The Syncthing Project" \
+      org.opencontainers.image.licenses="MPL-2.0" \
+      org.opencontainers.image.title="Syncthing Discovery Server"
+
+EXPOSE 19200 8443
+
+VOLUME ["/var/stdiscosrv"]
+
+RUN apk add --no-cache ca-certificates su-exec
+
+COPY --from=builder /src/stdiscosrv-linux-$TARGETARCH /bin/stdiscosrv
+COPY --from=builder /src/script/docker-entrypoint.sh /bin/entrypoint.sh
+
+ENV PUID=1000 PGID=1000 HOME=/var/stdiscosrv
+
+HEALTHCHECK --interval=1m --timeout=10s \
+  CMD nc -z localhost 8443 || exit 1
+
+WORKDIR /var/stdiscosrv
+ENTRYPOINT ["/bin/entrypoint.sh", "/bin/stdiscosrv"]

+ 44 - 0
syncthing/Dockerfile.strelaysrv

@@ -0,0 +1,44 @@
+ARG GOVERSION=latest
+FROM golang:$GOVERSION AS builder
+ARG BUILD_USER
+ARG BUILD_HOST
+ARG TARGETARCH
+
+ADD https://github.com/syncthing/syncthing/archive/refs/heads/main.zip /tmp/
+RUN apt-get update && apt-get install unzip git -y && unzip /tmp/main.zip -d /tmp && mv /tmp/syncthing-main /src
+
+WORKDIR /src
+
+ENV CGO_ENABLED=0
+RUN if [ ! -f strelaysrv-linux-$TARGETARCH ] ; then \
+    go run build.go -no-upgrade build strelaysrv ; \
+    mv strelaysrv strelaysrv-linux-$TARGETARCH ; \
+  fi
+
+FROM alpine
+ARG TARGETARCH
+
+LABEL org.opencontainers.image.authors="The Syncthing Project" \
+      org.opencontainers.image.url="https://syncthing.net" \
+      org.opencontainers.image.documentation="https://docs.syncthing.net" \
+      org.opencontainers.image.source="https://github.com/syncthing/syncthing" \
+      org.opencontainers.image.vendor="The Syncthing Project" \
+      org.opencontainers.image.licenses="MPL-2.0" \
+      org.opencontainers.image.title="Syncthing Relay Server"
+
+EXPOSE 22067 22070
+
+VOLUME ["/var/strelaysrv"]
+
+RUN apk add --no-cache ca-certificates su-exec
+
+COPY --from=builder /src/strelaysrv-linux-$TARGETARCH /bin/strelaysrv
+COPY --from=builder /src/script/docker-entrypoint.sh /bin/entrypoint.sh
+
+ENV PUID=1000 PGID=1000 HOME=/var/strelaysrv
+
+HEALTHCHECK --interval=1m --timeout=10s \
+  CMD nc -z localhost 22067 || exit 1
+
+WORKDIR /var/strelaysrv
+ENTRYPOINT ["/bin/entrypoint.sh", "/bin/strelaysrv"]

+ 0 - 63
syncthing/Dockerfile.test

@@ -1,63 +0,0 @@
-ARG GOVERSION=latest
-
-#
-# Maybe build Syncthing. This is a bit ugly as we can't make an entire
-# section of the Dockerfile conditional, so we end up always pulling the
-# golang image as builder. Then we check if the executable we need already
-# exists (pre-built) otherwise we build it.
-#
-
-FROM golang:$GOVERSION AS builder
-ARG BUILD_USER
-ARG BUILD_HOST
-ARG TARGETARCH
-
-ADD https://github.com/syncthing/syncthing/archive/refs/heads/main.zip /tmp/
-
-RUN apt-get update && \
-    apt-get install unzip git -y && \
-    unzip /tmp/main.zip -d /tmp && \
-    mv /tmp/syncthing-main /src && \
-    ls -la /src
-
-WORKDIR /src
-ENV CGO_ENABLED=0
-RUN if [ ! -f syncthing-linux-$TARGETARCH ] ; then \
-    go run build.go -no-upgrade build syncthing ; \
-    mv syncthing syncthing-linux-$TARGETARCH ; \
-  fi
-
-#
-# The rest of the Dockerfile uses the binary from the builder, prebuilt or
-# not.
-#
-
-FROM alpine
-ARG TARGETARCH
-
-LABEL org.opencontainers.image.authors="The Syncthing Project" \
-      org.opencontainers.image.url="https://syncthing.net" \
-      org.opencontainers.image.documentation="https://docs.syncthing.net" \
-      org.opencontainers.image.source="https://github.com/syncthing/syncthing" \
-      org.opencontainers.image.vendor="The Syncthing Project" \
-      org.opencontainers.image.licenses="MPL-2.0" \
-      org.opencontainers.image.title="Syncthing"
-
-EXPOSE 8384 22000/tcp 22000/udp 21027/udp
-
-VOLUME ["/var/syncthing"]
-
-RUN apk add --no-cache ca-certificates curl libcap su-exec tzdata
-
-COPY --from=builder /src/syncthing-linux-$TARGETARCH /bin/syncthing
-COPY --from=builder /src/script/docker-entrypoint.sh /bin/entrypoint.sh
-
-ENV PUID=1000 PGID=1000 HOME=/var/syncthing
-
-HEALTHCHECK --interval=1m --timeout=10s \
-  CMD curl -fkLsS -m 2 127.0.0.1:8384/rest/noauth/health | grep -o --color=never OK || exit 1
-
-ENV STGUIADDRESS=0.0.0.0:8384
-ENV STHOMEDIR=/var/syncthing/config
-RUN chmod 755 /bin/entrypoint.sh
-ENTRYPOINT ["/bin/entrypoint.sh", "/bin/syncthing"]