From e02cedc84d386ec191db2fc22cd9cb294c365554 Mon Sep 17 00:00:00 2001 From: Sheogorath <sheogorath@shivering-isles.com> Date: Mon, 4 Sep 2023 03:55:47 +0200 Subject: [PATCH] feat(findmydevice): Build patched image in CI This patch provides my adjusted image as part of the GitOps Repository CI. The image was patched to listen on an unprivileged port by default. It patches the go code, since the providing the configfile is untrivial to provide as configmap and environment variables are no option. Otherwise the Earthfile reproduces the upstream Dockerfile. References: https://gitlab.com/Nulide/findmydeviceserver/-/blob/210898cbe631663cf42cbb1f05fd09384913a6aa/Dockerfile https://www.w3.org/Daemon/User/Installation/PrivilegedPorts.html --- charts/findmydevice/Chart.yaml | 4 +- charts/findmydevice/README.md | 4 +- charts/findmydevice/values.yaml | 2 +- images/.utils/gitlab-ci.yaml | 1 + images/findmydevice-server/.release | 1 + images/findmydevice-server/Earthfile | 57 ++++++++++++++++++++++++++++ 6 files changed, 64 insertions(+), 5 deletions(-) create mode 100644 images/findmydevice-server/.release create mode 100644 images/findmydevice-server/Earthfile diff --git a/charts/findmydevice/Chart.yaml b/charts/findmydevice/Chart.yaml index beb15bcb6..54cfe04e9 100644 --- a/charts/findmydevice/Chart.yaml +++ b/charts/findmydevice/Chart.yaml @@ -12,5 +12,5 @@ sources: type: application -version: 0.1.0 -appVersion: "0.4.1-deploy" +version: 0.1.1 +appVersion: "0.4.0" diff --git a/charts/findmydevice/README.md b/charts/findmydevice/README.md index 188d2c113..846f51876 100644 --- a/charts/findmydevice/README.md +++ b/charts/findmydevice/README.md @@ -1,6 +1,6 @@ # findmydevice -   +   A Helm chart for the findmydevice (FMD) server. A project for Android and linux that allows "Find my Phone"-functionality as known from Apple and Google, without handing data over to them. @@ -18,7 +18,7 @@ A Helm chart for the findmydevice (FMD) server. A project for Android and linux | affinity | object | `{}` | | | fullnameOverride | string | `""` | | | image.pullPolicy | string | `"IfNotPresent"` | Pull policy allows to configure whether an image should be used if already on the host or pulled freshly regardless. | -| image.repository | string | `"registry.shivering-isles.com/sheogorath/findmydevice-server"` | Container registry image to use | +| image.repository | string | `"quay.io/shivering-isles/findmydevice-server"` | Container registry image to use | | image.tag | string | `""` | Overrides the image tag whose default is the chart appVersion. | | imagePullSecrets | list | `[]` | | | ingress.annotations | object | `{}` | | diff --git a/charts/findmydevice/values.yaml b/charts/findmydevice/values.yaml index cdafac4ea..c685fcb8a 100644 --- a/charts/findmydevice/values.yaml +++ b/charts/findmydevice/values.yaml @@ -1,7 +1,7 @@ --- image: # -- Container registry image to use - repository: registry.shivering-isles.com/sheogorath/findmydevice-server + repository: quay.io/shivering-isles/findmydevice-server # -- Pull policy allows to configure whether an image should be used if already on the host or pulled freshly regardless. pullPolicy: IfNotPresent # -- Overrides the image tag whose default is the chart appVersion. diff --git a/images/.utils/gitlab-ci.yaml b/images/.utils/gitlab-ci.yaml index cdb619a81..7efcaf881 100644 --- a/images/.utils/gitlab-ci.yaml +++ b/images/.utils/gitlab-ci.yaml @@ -7,6 +7,7 @@ - koolbox - synadm - query-exposer + - findmydevice-server earthly: stage: build diff --git a/images/findmydevice-server/.release b/images/findmydevice-server/.release new file mode 100644 index 000000000..9ecf65833 --- /dev/null +++ b/images/findmydevice-server/.release @@ -0,0 +1 @@ +release=0.4.0 diff --git a/images/findmydevice-server/Earthfile b/images/findmydevice-server/Earthfile new file mode 100644 index 000000000..4c5799e49 --- /dev/null +++ b/images/findmydevice-server/Earthfile @@ -0,0 +1,57 @@ +VERSION 0.7 + +builder: + FROM docker.io/library/golang:bullseye + + WORKDIR /go/src/findmydeviceserver + ENV GOPATH /go + + RUN apt update && apt install -y npm + + GIT CLONE --keep-ts --branch=v0.4.0 https://gitlab.com/Nulide/findmydeviceserver.git ./ + RUN sed 's/1020/8080/' cmd/fmdserver.go + RUN sed 's/1008/8443/' cmd/fmdserver.go + + RUN curl -L https://raw.githubusercontent.com/objectbox/objectbox-go/main/install.sh > objectbox-install.sh + RUN bash ./objectbox-install.sh + + RUN go build -o /fmd cmd/fmdserver.go + RUN npm install + + SAVE ARTIFACT /usr/lib/libobjectbox.so ./libobjectbox.so + SAVE ARTIFACT /go/src/findmydeviceserver/node_modules ./node_modules + SAVE ARTIFACT /fmd ./server + SAVE ARTIFACT ./extra ./extra + SAVE ARTIFACT ./web ./web + + +container: + FROM docker.io/library/debian:bullseye-slim + + ARG registry=quay.io/shivering-isles/findmydevice-server + COPY .release ./ + ARG tag=$(awk -F'=' '$1 == "release" {print $2}' .release) + ARG latest=false + + RUN apt update && apt install -y ca-certificates && rm -rf /var/lib/apt/lists/* + + COPY +builder/server /fmd/server + COPY +builder/node_modules /fmd/web/node_modules + COPY +builder/libobjectbox.so /usr/lib/libobjectbox.so + + COPY +builder/web /fmd/web + COPY +builder/extra /fmd/extra + + RUN useradd -m -u 1000 user + RUN mkdir /fmd/objectbox \ + && chown user:user /fmd/objectbox + USER 1000 + + EXPOSE 8080/tcp + + ENTRYPOINT ["/fmd/server"] + + IF [ $latest = "true" ] + SAVE IMAGE --push ${registry}:latest + END + SAVE IMAGE --push ${registry}:${tag} -- GitLab