From 5a1f996e56c2bd5d72974efe04819c5df4395dcf Mon Sep 17 00:00:00 2001 From: Jakob Borg Date: Sat, 1 Jul 2023 07:53:04 +0200 Subject: [PATCH] build: Build infrastructure images --- .github/workflows/build-infra-dockers.yaml | 54 ++++++++++++++++++++++ Dockerfile.stcrashreceiver | 14 +----- Dockerfile.strelaypoolsrv | 16 ++----- Dockerfile.stupgrades | 14 +----- 4 files changed, 61 insertions(+), 37 deletions(-) create mode 100644 .github/workflows/build-infra-dockers.yaml diff --git a/.github/workflows/build-infra-dockers.yaml b/.github/workflows/build-infra-dockers.yaml new file mode 100644 index 000000000..2295fedb1 --- /dev/null +++ b/.github/workflows/build-infra-dockers.yaml @@ -0,0 +1,54 @@ +name: Build Infrastructure Images + +on: + push: + branches: + - infrastructure + +env: + GO_VERSION: "^1.20.5" + CGO_ENABLED: "0" + BUILD_USER: docker + BUILD_HOST: github.syncthing.net + +jobs: + + docker-syncthing: + name: Build and push Docker images + runs-on: ubuntu-latest + environment: docker + strategy: + matrix: + pkg: + - stcrashreceiver + - strelaypoolsrv + - stupgrades + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Login to Docker Hub + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Build binaries + run: | + for arch in arm64 amd64; do + go run build.go -goos linux -goarch "$arch" build ${{ matrix.pkg }} + mv ${{ matrix.pkg }} ${{ matrix.pkg }}-linux-"$arch" + done + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + + - name: Build and push + uses: docker/build-push-action@v4 + with: + context: . + file: ./Dockerfile.${{ matrix.pkg }} + platforms: linux/amd64,linux/arm64 + push: true + tags: syncthing/${{ matrix.pkg }}:latest,syncthing/${{ matrix.pkg }}:${{ github.sha }} diff --git a/Dockerfile.stcrashreceiver b/Dockerfile.stcrashreceiver index 4f6e60986..a29eb1de5 100644 --- a/Dockerfile.stcrashreceiver +++ b/Dockerfile.stcrashreceiver @@ -1,18 +1,8 @@ -ARG GOVERSION=latest -FROM golang:$GOVERSION AS builder - -WORKDIR /src -COPY . . - -ENV CGO_ENABLED=0 -ENV BUILD_HOST=syncthing.net -ENV BUILD_USER=docker -RUN rm -f stcrashreceiver && go run build.go build stcrashreceiver - FROM alpine +ARG TARGETARCH EXPOSE 8080 -COPY --from=builder /src/stcrashreceiver /bin/stcrashreceiver +COPY stcrashreceiver-linux-${TARGETARCH} /bin/stcrashreceiver ENTRYPOINT [ "/bin/stcrashreceiver" ] diff --git a/Dockerfile.strelaypoolsrv b/Dockerfile.strelaypoolsrv index 814948b25..4519f09e1 100644 --- a/Dockerfile.strelaypoolsrv +++ b/Dockerfile.strelaypoolsrv @@ -1,15 +1,5 @@ -ARG GOVERSION=latest -FROM golang:$GOVERSION AS builder - -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 strelaypoolsrv - FROM alpine +ARG TARGETARCH EXPOSE 8080 @@ -19,8 +9,8 @@ ENV PUID=1000 PGID=1000 MAXMIND_KEY= RUN mkdir /var/strelaypoolsrv && chown 1000 /var/strelaypoolsrv USER 1000 -COPY --from=builder /src/strelaypoolsrv /bin/strelaypoolsrv -COPY --from=builder /src/script/strelaypoolsrv-entrypoint.sh /bin/entrypoint.sh +COPY strelaypoolsrv-linux-${TARGETARCH} /bin/strelaypoolsrv +COPY script/strelaypoolsrv-entrypoint.sh /bin/entrypoint.sh WORKDIR /var/strelaypoolsrv ENTRYPOINT ["/bin/entrypoint.sh", "/bin/strelaypoolsrv", "-listen", ":8080"] diff --git a/Dockerfile.stupgrades b/Dockerfile.stupgrades index 896d83e82..c4e65b998 100644 --- a/Dockerfile.stupgrades +++ b/Dockerfile.stupgrades @@ -1,18 +1,8 @@ -ARG GOVERSION=latest -FROM golang:$GOVERSION AS builder - -WORKDIR /src -COPY . . - -ENV CGO_ENABLED=0 -ENV BUILD_HOST=syncthing.net -ENV BUILD_USER=docker -RUN rm -f stupgrades && go run build.go build stupgrades - FROM alpine +ARG TARGETARCH EXPOSE 8080 -COPY --from=builder /src/stupgrades /bin/stupgrades +COPY stupgrades-linux-${TARGETARCH} /bin/stupgrades ENTRYPOINT [ "/bin/stupgrades" ]