From 7898e07eafbf17cc29bfd6897914bb73df0a4b95 Mon Sep 17 00:00:00 2001 From: Ricard Illa Date: Wed, 25 May 2022 11:34:36 +0200 Subject: [PATCH] updated syncthing image --- syncthing/Dockerfile | 45 +++++++++++++++++----------------- syncthing/Makefile | 25 ++++++++++++------- syncthing/docker-entrypoint.sh | 9 ------- 3 files changed, 38 insertions(+), 41 deletions(-) delete mode 100644 syncthing/docker-entrypoint.sh diff --git a/syncthing/Dockerfile b/syncthing/Dockerfile index 0f8c645..6a0b6be 100644 --- a/syncthing/Dockerfile +++ b/syncthing/Dockerfile @@ -1,30 +1,29 @@ # syncthing -FROM alpine:3.14 +FROM alpine:3.15 -ARG ARCH -ENV VER v1.18.3 -ENV REL syncthing-linux-${ARCH}-${VER} -ENV URI https://github.com/syncthing/syncthing/releases/download/${VER}/${REL}.tar.gz +ARG TARGETPLATFORM +ENV VERSION v1.20.1 -RUN apk add --no-cache su-exec - -RUN adduser -u 1001 -h /var/lib/syncthing -D syncthing && \ - addgroup -S -g 1005 books && addgroup syncthing books && \ - addgroup -S -g 1006 buku && addgroup syncthing buku - -RUN mkdir -p /data && chown -R syncthing:syncthing /data +RUN addgroup --gid 10001 syncthing && \ + adduser \ + --uid 10000 \ + --home /var/lib/syncthing \ + --ingroup syncthing \ + --disabled-password \ + --shell /sbin/nologin \ + syncthing && \ + mkdir -p /data && chown -R syncthing:syncthing /data && \ + cd /tmp && \ + ARCH=$(echo "$TARGETPLATFORM" | sed 's/\//-/') && \ + RELEASE="syncthing-${ARCH}-${VERSION}" && \ + URI="https://github.com/syncthing/syncthing/releases/download/${VERSION}/${RELEASE}.tar.gz" && \ + echo "$URI" && \ + wget "${URI}" && \ + tar -xzf "${RELEASE}.tar.gz" && \ + cp "/tmp/${RELEASE}/syncthing" /usr/local/bin/syncthing && \ + rm -r "/tmp/${RELEASE}" "/tmp/${RELEASE}.tar.gz" VOLUME /data /var/lib/syncthing - -RUN cd /tmp && \ - wget ${URI} && \ - tar -xzf ${REL}.tar.gz && \ - cp /tmp/${REL}/syncthing /usr/local/bin/syncthing && \ - rm -r /tmp/${REL} /tmp/${REL}.tar.gz - -COPY docker-entrypoint.sh /entrypoint - -RUN chmod +x /entrypoint -ENTRYPOINT ["/entrypoint"] +USER syncthing CMD ["/usr/local/bin/syncthing", "-home=/var/lib/syncthing"] diff --git a/syncthing/Makefile b/syncthing/Makefile index 9db4404..5341772 100644 --- a/syncthing/Makefile +++ b/syncthing/Makefile @@ -1,24 +1,31 @@ IMG_NAME = syncthing -REGISTRY=registry.monotremata.xyz:443 - +REGISTRY=registry.monotremata.xyz IMG=$(REGISTRY)/$(IMG_NAME) +PLATFORMS=linux/amd64,linux/arm64 -.PHONY: build build-nc push +.PHONY: build build-nc buildx push hw=$(shell uname -m) ifeq ($(hw), x86_64) - ARCH=amd64 + TARGETPLATFORM=linux/amd64 else ifeq ($(hw), aarch64) - ARCH=arm64 + TARGETPLATFORM=linux/arm64 else - ARCH=$(hw) + TARGETPLATFORM=linux/$(hw) endif -build: Dockerfile docker-entrypoint.sh - docker build -t $(IMG) --build-arg ARCH=$(ARCH) . +build: Dockerfile + docker build -t $(IMG) --build-arg TARGETPLATFORM=$(TARGETPLATFORM) . + +buildx: Dockerfile + docker buildx build \ + --platform $(PLATFORMS) \ + --tag $(IMG) \ + --push \ + . push: build docker image push $(IMG) -build-nc: Dockerfile docker-entrypoint.sh +build-nc: Dockerfile docker build --no-cache -t $(IMG) --build-arg ARCH=$(ARCH) . diff --git a/syncthing/docker-entrypoint.sh b/syncthing/docker-entrypoint.sh deleted file mode 100644 index e96a87c..0000000 --- a/syncthing/docker-entrypoint.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/sh - -chown -R syncthing:syncthing /data -chown -R syncthing:syncthing /var/lib/syncthing -chown -R syncthing:books /data/books -chown -R syncthing:buku /data/buku && touch /data/buku/bookmarks.db && chmod '664' /data/buku/bookmarks.db -chmod '2775' /data/books - -exec su-exec syncthing "$@"