aboutsummaryrefslogtreecommitdiff
path: root/Dockerfile
diff options
context:
space:
mode:
authorJakob Borg <jakob@kastelo.net>2023-06-14 09:23:52 +0200
committerJakob Borg <jakob@kastelo.net>2023-06-14 09:28:04 +0200
commit439fa6c84861cfb22c8faec962302c1f332f705d (patch)
tree46f40673a32852b69d4b503cbbf5e55c8a0d7cb2 /Dockerfile
parent6b475bdb78eb671866419ff84a4cda6285c90244 (diff)
downloadsyncthing-439fa6c84861cfb22c8faec962302c1f332f705d.tar.gz
syncthing-439fa6c84861cfb22c8faec962302c1f332f705d.zip
build: Multi arch Docker images with GitHub actions (ref #8834)
This builds and publishes our Docker images from GitHub.
Diffstat (limited to 'Dockerfile')
-rw-r--r--Dockerfile26
1 files changed, 22 insertions, 4 deletions
diff --git a/Dockerfile b/Dockerfile
index c2c93f7b8..4ecc0f52e 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -1,15 +1,33 @@
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
WORKDIR /src
COPY . .
ENV CGO_ENABLED=0
-ENV BUILD_HOST=syncthing.net
-ENV BUILD_USER=docker
-RUN rm -f syncthing && go run build.go -no-upgrade build syncthing
+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
EXPOSE 8384 22000/tcp 22000/udp 21027/udp
@@ -17,7 +35,7 @@ VOLUME ["/var/syncthing"]
RUN apk add --no-cache ca-certificates curl libcap su-exec tzdata
-COPY --from=builder /src/syncthing /bin/syncthing
+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