aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakob Borg <jakob@kastelo.net>2023-07-01 08:35:41 +0200
committerJakob Borg <jakob@kastelo.net>2023-07-01 08:48:12 +0200
commit465823237f75c82a2f36bbba60dd0b8af8619f36 (patch)
treeed08d040d136cf9220564b624a16edcd5f18dd0d
parent5a1f996e56c2bd5d72974efe04819c5df4395dcf (diff)
downloadsyncthing-465823237f75c82a2f36bbba60dd0b8af8619f36.tar.gz
syncthing-465823237f75c82a2f36bbba60dd0b8af8619f36.zip
build: Build and publish Docker images for relay and discovery server (fixes #8691, fixes #8960)
This adds builds for the discovery and relay servers in the same manner as Syncthing, so that Docker images are kept up to date with releases. Inspired by and closes #8834. Co-authored-by: Migelo <miha@filetki.si>
-rw-r--r--.github/workflows/build-syncthing.yaml29
-rw-r--r--Dockerfile.stdiscosrv13
-rw-r--r--Dockerfile.strelaysrv13
3 files changed, 39 insertions, 16 deletions
diff --git a/.github/workflows/build-syncthing.yaml b/.github/workflows/build-syncthing.yaml
index 1366122c5..75c05004c 100644
--- a/.github/workflows/build-syncthing.yaml
+++ b/.github/workflows/build-syncthing.yaml
@@ -647,6 +647,19 @@ jobs:
runs-on: ubuntu-latest
if: github.event_name == 'push' && (github.ref == 'refs/heads/release' || github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/heads/release-'))
environment: docker
+ strategy:
+ matrix:
+ pkg:
+ - syncthing
+ - strelaysrv
+ - stdiscosrv
+ include:
+ - pkg: syncthing
+ dockerfile: Dockerfile
+ - pkg: strelaysrv
+ dockerfile: Dockerfile.strelaysrv
+ - pkg: stdiscosrv
+ dockerfile: Dockerfile.stdiscosrv
steps:
- uses: actions/checkout@v3
with:
@@ -663,13 +676,13 @@ jobs:
path: |
~/.cache/go-build
~/go/pkg/mod
- key: ${{ runner.os }}-go-${{ env.GO_VERSION }}-docker-${{ hashFiles('**/go.sum') }}
+ key: ${{ runner.os }}-go-${{ env.GO_VERSION }}-docker-${{ matrix.pkg }}-${{ hashFiles('**/go.sum') }}
- name: Build binaries
run: |
for arch in arm64 amd64; do
- go run build.go -goos linux -goarch "$arch" -no-upgrade build syncthing
- mv syncthing syncthing-linux-"$arch"
+ go run build.go -goos linux -goarch "$arch" -no-upgrade build ${{ matrix.pkg }}
+ mv ${{ matrix.pkg }} ${{ matrix.pkg }}-linux-"$arch"
done
env:
CGO_ENABLED: "0"
@@ -692,21 +705,21 @@ jobs:
echo Release version, pushing to :latest and version tags
major=${version%.*.*}
minor=${version%.*}
- tags=syncthing/syncthing:$version,syncthing/syncthing:$major,syncthing/syncthing:$minor,syncthing/syncthing:latest
+ tags=syncthing/${{ matrix.pkg }}:$version,syncthing/${{ matrix.pkg }}:$major,syncthing/${{ matrix.pkg }}:$minor,syncthing/${{ matrix.pkg }}:latest
elif [[ $version == *-rc.@([0-9]|[0-9][0-9]) ]] ; then
echo Release candidate, pushing to :rc
- tags=syncthing/syncthing:rc
+ tags=syncthing/${{ matrix.pkg }}:rc
else
echo Development version, pushing to :edge
- tags=syncthing/syncthing:edge
+ tags=syncthing/${{ matrix.pkg }}:edge
fi
echo "DOCKER_TAGS=$tags" >> $GITHUB_ENV
- - name: Build and push syncthing
+ - name: Build and push Docker image
uses: docker/build-push-action@v4
with:
context: .
- file: ./Dockerfile
+ file: ${{ matrix.dockerfile }}
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ env.DOCKER_TAGS }}
diff --git a/Dockerfile.stdiscosrv b/Dockerfile.stdiscosrv
index 2373b7cd9..6adb5dcc3 100644
--- a/Dockerfile.stdiscosrv
+++ b/Dockerfile.stdiscosrv
@@ -1,15 +1,20 @@
ARG GOVERSION=latest
FROM golang:$GOVERSION AS builder
+ARG BUILD_USER
+ARG BUILD_HOST
+ARG TARGETARCH
WORKDIR /src
COPY . .
ENV CGO_ENABLED=0
-ENV BUILD_HOST=syncthing.net
-ENV BUILD_USER=docker
-RUN rm -f stdiscosrv && go run build.go -no-upgrade build stdiscosrv
+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
EXPOSE 19200 8443
@@ -17,7 +22,7 @@ VOLUME ["/var/stdiscosrv"]
RUN apk add --no-cache ca-certificates su-exec
-COPY --from=builder /src/stdiscosrv /bin/stdiscosrv
+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
diff --git a/Dockerfile.strelaysrv b/Dockerfile.strelaysrv
index 26bbf0098..841d2feb3 100644
--- a/Dockerfile.strelaysrv
+++ b/Dockerfile.strelaysrv
@@ -1,15 +1,20 @@
ARG GOVERSION=latest
FROM golang:$GOVERSION AS builder
+ARG BUILD_USER
+ARG BUILD_HOST
+ARG TARGETARCH
WORKDIR /src
COPY . .
ENV CGO_ENABLED=0
-ENV BUILD_HOST=syncthing.net
-ENV BUILD_USER=docker
-RUN rm -f strelaysrv && go run build.go -no-upgrade build strelaysrv
+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
EXPOSE 22067 22070
@@ -17,7 +22,7 @@ VOLUME ["/var/strelaysrv"]
RUN apk add --no-cache ca-certificates su-exec
-COPY --from=builder /src/strelaysrv /bin/strelaysrv
+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