From d8a038ea15e24bb061ba717f286d515fce0d440b Mon Sep 17 00:00:00 2001 From: Gitouche <26656-gitouche@users.noreply.framagit.org> Date: Tue, 15 Nov 2022 19:16:59 +0100 Subject: [PATCH] ntfy : build images --- .gitlab-ci.yml | 9 +++++++++ podman-ntfy/.gitlab-ci.yml | 12 +++++++++++ podman-ntfy/ci_build-images.sh | 20 ++++++++++++++++++ podman-ntfy/docker/Dockerfile | 37 ++++++++++++++++++++++++++++++++++ podman-ntfy/vars.sh | 13 ++++++++++++ 5 files changed, 91 insertions(+) create mode 100644 podman-ntfy/.gitlab-ci.yml create mode 100755 podman-ntfy/ci_build-images.sh create mode 100644 podman-ntfy/docker/Dockerfile create mode 100644 podman-ntfy/vars.sh diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 1c87572..04782d9 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -37,6 +37,15 @@ trigger_matrix: - changes: - podman-matrix/* +trigger_ntfy: + stage: triggers + trigger: + include: podman-ntfy/.gitlab-ci.yml + strategy: depend + rules: + - changes: + - podman-ntfy/* + trigger_peerjs: stage: triggers trigger: diff --git a/podman-ntfy/.gitlab-ci.yml b/podman-ntfy/.gitlab-ci.yml new file mode 100644 index 0000000..1018c40 --- /dev/null +++ b/podman-ntfy/.gitlab-ci.yml @@ -0,0 +1,12 @@ +# Si besoin d'executer le before_script manuellement : +# sed -n 's/^ - \(.*\)$/\1/p' .gitlab-ci.yml | bash +ntfy: + stage: test + script: + - cd podman-ntfy + - ./ci_build-images.sh + tags: + - garbaye + - compute + - podman + - x86_64 diff --git a/podman-ntfy/ci_build-images.sh b/podman-ntfy/ci_build-images.sh new file mode 100755 index 0000000..7f535f9 --- /dev/null +++ b/podman-ntfy/ci_build-images.sh @@ -0,0 +1,20 @@ +#!/usr/bin/env bash + +ABSDIR="$( dirname "$(readlink -f -- "$0")" )" +source ${ABSDIR}/../functions.sh +source ${ABSDIR}/vars.sh + +ensure_pwd_is_scriptdir +ensure_not_root + +if ! podman image exists ${ntfy_image}:${ntfy_version}; then + TMPDIR=${HOME} podman build -t "${ntfy_image}:${ntfy_version}" docker/ --build-arg NTFY_VERSION=${ntfy_version} + podman image prune -a -f --filter dangling=true + podman image prune -a -f --filter intermediate=true + podman image rm -f $(podman images -a -q -- docker.io/library/golang) + podman image rm -f $(podman images -a -q -- docker.io/library/alpine) +else + echo "Image ${ntfy_image}:${ntfy_version} already built" +fi + +oci_push_to_registry ${ntfy_image}:${ntfy_version} diff --git a/podman-ntfy/docker/Dockerfile b/podman-ntfy/docker/Dockerfile new file mode 100644 index 0000000..217087c --- /dev/null +++ b/podman-ntfy/docker/Dockerfile @@ -0,0 +1,37 @@ +#Build stage +FROM golang:1.19-alpine3.16 AS build-env + +ARG NTFY_VERSION + +#Build deps +RUN apk --no-cache add build-base git nodejs npm upx py3-pip + +#Install gorealeaser +RUN go install github.com/goreleaser/goreleaser@latest + +#Setup repo +RUN git clone --depth=1 -b "${NTFY_VERSION}" https://github.com/binwiederhier/ntfy.git + +#Build +RUN cd ntfy && make web && make docs && make cli-linux-amd64 + +FROM alpine:3.16 +LABEL maintainer="contact@garbaye.fr" + +EXPOSE 80/tcp + +RUN adduser \ + -S -H -D \ + ntfy && \ +mkdir /etc/ntfy && \ +chown ntfy:nogroup /etc/ntfy && \ +mkdir /var/cache/ntfy && \ +chown ntfy:nogroup /var/cache/ntfy + +USER ntfy + +ENTRYPOINT ["ntfy"] + +COPY --from=build-env /go/ntfy/dist/ntfy_linux_amd64_linux_amd64_v1/ntfy /usr/bin/ntfy + +# podman run --rm -p 3333:3333 -it localhost/ntfy:v1.29.0 serve --listen-http :3333 diff --git a/podman-ntfy/vars.sh b/podman-ntfy/vars.sh new file mode 100644 index 0000000..8c62232 --- /dev/null +++ b/podman-ntfy/vars.sh @@ -0,0 +1,13 @@ +#!/usr/bin/env bash +## vars +ntfy_image="git.garbaye.fr/garbaye/ntfy" +ntfy_version='v1.29.0' +## default vars : override with ENV var +## mandatory ENV vars +## internal vars : do not touch +project_name=${PWD##*/} +container_name="${project_name}" +service_name="container-${container_name}.service" +cachevolume='podman-ntfy_cache' +container_name='ntfy' +