Skip to content

Commit

Permalink
build: Pre-build binaries for infrastructure images
Browse files Browse the repository at this point in the history
Building dual-architecture images under emulation takes a thousand
years.
  • Loading branch information
calmh committed Jul 1, 2023
1 parent 7688409 commit 8b245b7
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 39 deletions.
15 changes: 14 additions & 1 deletion .github/workflows/build-infra-dockers.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ on:
branches:
- infrastructure

env:
GO_VERSION: "^1.20.5"
CGO_ENABLED: "0"
BUILD_USER: docker
BUILD_HOST: github.syncthing.net

jobs:

docker-syncthing:
Expand All @@ -28,6 +34,13 @@ jobs:
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

Expand All @@ -38,4 +51,4 @@ jobs:
file: ./Dockerfile.${{ matrix.pkg }}
platforms: linux/amd64,linux/arm64
push: true
tags: syncthing/${{ matrix.pkg }}:latest
tags: syncthing/${{ matrix.pkg }}:latest syncthing/${{ matrix.pkg }}:${{ github.sha }}
14 changes: 2 additions & 12 deletions Dockerfile.stcrashreceiver
Original file line number Diff line number Diff line change
@@ -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" ]
16 changes: 3 additions & 13 deletions Dockerfile.strelaypoolsrv
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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"]
16 changes: 3 additions & 13 deletions Dockerfile.strelaysrv
Original file line number Diff line number Diff line change
@@ -1,24 +1,14 @@
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 strelaysrv

FROM alpine
ARG TARGETARCH

EXPOSE 22067 22070

VOLUME ["/var/strelaysrv"]

RUN apk add --no-cache ca-certificates su-exec

COPY --from=builder /src/strelaysrv /bin/strelaysrv
COPY --from=builder /src/script/docker-entrypoint.sh /bin/entrypoint.sh
COPY strelaysrv-linux-${TARGETARCH} /bin/strelaysrv
COPY script/docker-entrypoint.sh /bin/entrypoint.sh

ENV PUID=1000 PGID=1000 HOME=/var/strelaysrv

Expand Down

0 comments on commit 8b245b7

Please sign in to comment.