From 920b017342d42149fd0774bbdbe5137f51c01d80 Mon Sep 17 00:00:00 2001 From: RouxAntoine Date: Wed, 2 Aug 2023 21:35:49 +0200 Subject: [PATCH] feature: running image first version --- Dockerfile | 53 ++++++++++++++++++++++++++++++++++++++++++++ Makefile | 21 ++++++++++++++++++ docker-entrypoint.sh | 12 ++++++++++ server-config.json | 11 +++++++++ 4 files changed, 97 insertions(+) create mode 100644 Dockerfile create mode 100644 Makefile create mode 100644 docker-entrypoint.sh create mode 100644 server-config.json diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..f6e63d2 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,53 @@ +FROM golang:1.20.6-bookworm as builder + +ARG TARGETARCH +ARG TARGETOS + +ENV VERSION 498fcaa7c3413a2d9d0aaf67cfe5fdeec76bff71 + +RUN apt update -y && \ + mkdir /perkeep && \ + cd /perkeep && \ + git init && \ + git remote add origin https://github.com/perkeep/perkeep.git && \ + git fetch origin $VERSION && \ + git reset --hard FETCH_HEAD + +WORKDIR /perkeep + +RUN go run make.go --arch $TARGETARCH --os $TARGETOS + +FROM alpine:3.18.2 + +ENV USER perkeep +ENV GROUP perkeep +ENV UID 1000 +ENV GID 1001 + +RUN addgroup -S $GROUP --gid $GID && \ + adduser \ + --disabled-password \ + --gecos "" \ + --home "/$USER" \ + --shell "/bin/sh" \ + --ingroup "$GROUP" \ + --uid "$UID" \ + "$USER" && \ + apk add --no-cache libc6-compat gpg + +USER $USER + +RUN mkdir /perkeep/data && \ + mkdir /perkeep/config + +COPY --chown=$USER:$GROUP --chmod=750 --from=builder /go/bin/* /usr/local/bin/ +COPY --chown=$USER:$GROUP --chmod=750 server-config.json /perkeep/config/server-config-custom.json +COPY --chown=$USER:$GROUP --chmod=750 docker-entrypoint.sh /docker-entrypoint.sh + +VOLUME /perkeep/data +VOLUME /perkeep/config + +EXPOSE 3179 + +# /docker-entrypoint.sh perkeepd -configfile /perkeep/config/server-config-custom.json +ENTRYPOINT ["/docker-entrypoint.sh", "perkeepd", "-configfile", "/perkeep/config/server-config-custom.json"] \ No newline at end of file diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..4267e05 --- /dev/null +++ b/Makefile @@ -0,0 +1,21 @@ +.PHONY: imagePerkeep + +REGISTRY_NAME=docker.registry +# linux/arm/v7 +# linux/arm/v6 +# linux/arm64 +# linux/amd64 +PLATFORM=linux/amd64,linux/arm64 +#VERBOSITY=info +VERBOSITY=debug + +## build + +imagePerkeep: + docker manifest rm $(REGISTRY_NAME):5000/perkeep:latest || true + docker-multi-arch-builder build -n perkeep --platforms $(PLATFORM) -v $(VERBOSITY) + +## management + +status: + @curl -s $(REGISTRY_NAME):5000/v2/_catalog | jq \ No newline at end of file diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh new file mode 100644 index 0000000..ef2495c --- /dev/null +++ b/docker-entrypoint.sh @@ -0,0 +1,12 @@ +#!/bin/sh + +if [ ! -f /perkeep/config/identity-secring.gpg ]; +then + pk put init -newkey + mv perkeep/.config/perkeep/identity-secring.gpg /perkeep/config/ + IDENTITY=$(sed -n -e '/identity/ s/.*:.*"\(.*\)".*/\1/p' /perkeep/.config/perkeep/client-config.json | tee /dev/tty) + sed -i -e "s/TO_REPLACE/$IDENTITY/g" /perkeep/config/server-config-custom.json + rm -r /perkeep/.config +fi + +exec "$@" \ No newline at end of file diff --git a/server-config.json b/server-config.json new file mode 100644 index 0000000..c31bd7c --- /dev/null +++ b/server-config.json @@ -0,0 +1,11 @@ +{ + "auth": "localhost", + "listen": "0.0.0.0:3179", + "camliNetIP": "", + "identity": "TO_REPLACE", + "identitySecretRing": "/perkeep/config/identity-secring.gpg", + "blobPath": "/perkeep/data/blobs", + "packRelated": true, + "sqlite": "/perkeep/data/index.sqlite", + "shareHandler": false +} \ No newline at end of file