summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJakob Borg <jakob@kastelo.net>2023-06-14 08:40:19 +0200
committerJakob Borg <jakob@kastelo.net>2023-06-14 08:40:19 +0200
commitad8321222f024f2c97a0bbd9ea492aa57a139bab (patch)
tree01bec12f053df0e68e405f598251496647a5c1ea
parent7d56fba3217b94415ceced1b5041de34290f32d5 (diff)
wip
-rw-r--r--Dockerfile25
1 files changed, 21 insertions, 4 deletions
diff --git a/Dockerfile b/Dockerfile
index c2c93f7b8..646656f17 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -1,13 +1,30 @@
ARG GOVERSION=latest
+ARG TARGETARCH
+
+#
+# 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
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 ; \
+ fi && \
+ mv syncthing syncthing-linux-$TARGETARCH
+
+#
+# The rest of the Dockerfile uses the binary from the builder, prebuilt or
+# not.
+#
FROM alpine
@@ -17,7 +34,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