From d528292a08a16ccad5b8e7facf326c6eeaf9632e Mon Sep 17 00:00:00 2001 From: Thomas Legay Date: Tue, 5 Nov 2024 15:42:31 +0100 Subject: [PATCH] ajout de claper --- lib/exec_in_chroot.sh | 5 ++ ressources/claper/README.MD | 22 ++++++++ ressources/claper/debmaker | 42 +++++++++++++++ ressources/claper/rootfs/DEBIAN/changelog | 0 .../claper/rootfs/DEBIAN/claper.default | 53 +++++++++++++++++++ .../claper/rootfs/DEBIAN/claper.service | 19 +++++++ ressources/claper/rootfs/DEBIAN/conffiles | 1 + ressources/claper/rootfs/DEBIAN/control | 8 +++ ressources/claper/rootfs/DEBIAN/postinst | 5 ++ 9 files changed, 155 insertions(+) create mode 100644 ressources/claper/README.MD create mode 100755 ressources/claper/debmaker create mode 100644 ressources/claper/rootfs/DEBIAN/changelog create mode 100644 ressources/claper/rootfs/DEBIAN/claper.default create mode 100644 ressources/claper/rootfs/DEBIAN/claper.service create mode 100644 ressources/claper/rootfs/DEBIAN/conffiles create mode 100644 ressources/claper/rootfs/DEBIAN/control create mode 100755 ressources/claper/rootfs/DEBIAN/postinst diff --git a/lib/exec_in_chroot.sh b/lib/exec_in_chroot.sh index e3f4aa4..bf5b729 100755 --- a/lib/exec_in_chroot.sh +++ b/lib/exec_in_chroot.sh @@ -23,6 +23,11 @@ get_git_source(){ fi } +configure_depot_erlang_rabbitmq(){ + echo "deb [arch=amd64 signed-by=/usr/share/keyrings/erlang-rabbitmq.gpg] https://ppa1.rabbitmq.com/rabbitmq/rabbitmq-erlang/deb/debian bookworm main" > /etc/apt/sources.list.d/erlang.list + wget -qO - "https://github.com/rabbitmq/signing-keys/releases/download/3.0/cloudsmith.rabbitmq-erlang.E495BB49CC4BBE5B.key" | gpg --dearmor > /usr/share/keyrings/erlang-rabbitmq.gpg +} + configure_depot_yarn() { echo "deb [signed-by=/usr/share/keyrings/yarnkey.gpg] https://dl.yarnpkg.com/debian stable main" > /etc/apt/sources.list.d/yarn.list wget -qO - https://dl.yarnpkg.com/debian/pubkey.gpg | gpg --dearmor > /usr/share/keyrings/yarnkey.gpg diff --git a/ressources/claper/README.MD b/ressources/claper/README.MD new file mode 100644 index 0000000..c1cfd9c --- /dev/null +++ b/ressources/claper/README.MD @@ -0,0 +1,22 @@ +#### claper + +##### Information +Site : https://claper.co/ + +Doc : https://docs.claper.co/ + +Source : https://github.com/ClaperCo/Claper + +##### Install + +```bash +apt install -y wget ca-certificates +wget -qO - https://deb.lgy.fr/install.sh | bash +echo "deb [arch=amd64 signed-by=/usr/share/keyrings/erlang-rabbitmq.gpg] https://ppa1.rabbitmq.com/rabbitmq/rabbitmq-erlang/deb/debian bookworm main" > /etc/apt/sources.list.d/erlang.list +wget -qO - "https://github.com/rabbitmq/signing-keys/releases/download/3.0/cloudsmith.rabbitmq-erlang.E495BB49CC4BBE5B.key" | gpg --dearmor > /usr/share/keyrings/erlang-rabbitmq.gpg +apt-get update +apt-get install -y claper + +systemctl enable --now claper + +``` diff --git a/ressources/claper/debmaker b/ressources/claper/debmaker new file mode 100755 index 0000000..f1ddfef --- /dev/null +++ b/ressources/claper/debmaker @@ -0,0 +1,42 @@ +#!/bin/bash + +VERSION=2.1.1 +APP=claper +DEPOT=https://github.com/ClaperCo/Claper.git +GIT_VERSION=v${VERSION} +DEB_VERSION=${VERSION}-$(date +%Y%m%d%H%M) +DEBIAN_VERSION_CODENAME=bookworm +IMAGE_SIZE=5 +PACKAGE_DEPENDENCY="nodejs elixir npm erlang-dev erlang-syntax-tools make build-essential erlang-xmerl" + +main(){ + configure_depot_erlang_rabbitmq + base_package_upgrade + install_package_dependency + get_git_source + build + makedeb +} + +build() { + cd /tmp/${APP} + mix local.hex --force + mix deps.get + mix ecto.migrate + mix assets.deploy +} + +makedeb(){ + PATH_DEB=/tmp/src/rootfs + mkdir -p ${PATH_DEB}/opt/ + mkdir -p ${PATH_DEB}/etc/default/ + mkdir -p ${PATH_DEB}/usr/lib/systemd/system/ + + mv ${PATH_DEB}/DEBIAN/claper.default ${PATH_DEB}/etc/default/claper + mv ${PATH_DEB}/DEBIAN/claper.service ${PATH_DEB}/usr/lib/systemd/system/ + cp -fr /tmp/${APP} ${PATH_DEB}/opt/${APP} + cp -fr /root/.mix ${PATH_DEB}/opt/${APP} + + sed -i "s/%VERSION%/$DEB_VERSION/" ${PATH_DEB}/DEBIAN/control + fakeroot dpkg-deb -Z gzip --build ${PATH_DEB} /tmp/dist +} diff --git a/ressources/claper/rootfs/DEBIAN/changelog b/ressources/claper/rootfs/DEBIAN/changelog new file mode 100644 index 0000000..e69de29 diff --git a/ressources/claper/rootfs/DEBIAN/claper.default b/ressources/claper/rootfs/DEBIAN/claper.default new file mode 100644 index 0000000..bce80a4 --- /dev/null +++ b/ressources/claper/rootfs/DEBIAN/claper.default @@ -0,0 +1,53 @@ + +BASE_URL=https://domainer.com +# SAME_SITE_COOKIE=Lax +# SECURE_COOKIE=false + +DATABASE_URL=postgres://claper:xxxxxxxxxxx@postgresql:5432/claper +SECRET_KEY_BASE=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx +# ⚠️ Don't use this exact value for SECRET_KEY_BASE or someone would be able to sign a cookie with user_id=1 and log in as the admin! + +# Storage configuration + +PRESENTATION_STORAGE=local +PRESENTATION_STORAGE_DIR=priv/static +#MAX_FILE_SIZE_MB=15 + +#AWS_ACCESS_KEY_ID=xxx +#AWS_SECRET_ACCESS_KEY=xxx +#AWS_REGION=eu-west-3 +#AWS_PRES_BUCKET=xxx + +# Mail configuration + +MAIL_TRANSPORT=local +MAIL_FROM=noreply@claper.co +MAIL_FROM_NAME=Claper + +SMTP_RELAY=smtprelay +#SMTP_USERNAME=johndoe@example.com +#SMTP_PASSWORD=xxx +#SMTP_PORT=465 +#SMTP_TLS=if_available + +#ENABLE_MAILBOX_ROUTE=false +#MAILBOX_USER=admin +#MAILBOX_PASSWORD=admin + +# Claper configuration + +ENABLE_ACCOUNT_CREATION=false +#ALLOW_UNLINK_EXTERNAL_PROVIDER=false +#LOGOUT_REDIRECT_URL=https://google.com +#GS_JPG_RESOLUTION=300x300 + +# OIDC configuration + +#OIDC_PROVIDER_NAME="keycloak" +#OIDC_ISSUER= +#OIDC_CLIENT_ID= +#OIDC_CLIENT_SECRET= +# OIDC_SCOPES="openid email profile" +# OIDC_LOGO_URL="" +# OIDC_PROPERTY_MAPPINGS="roles:custom_attributes.roles,organization:custom_attributes.organization" +#OIDC_AUTO_REDIRECT_LOGIN=true diff --git a/ressources/claper/rootfs/DEBIAN/claper.service b/ressources/claper/rootfs/DEBIAN/claper.service new file mode 100644 index 0000000..0628cb7 --- /dev/null +++ b/ressources/claper/rootfs/DEBIAN/claper.service @@ -0,0 +1,19 @@ +[Unit] +Description=claper + +[Service] +User=claper +Group=claper +EnvironmentFile=/etc/default/claper +ExecStart=/usr/bin/mix phx.server +WorkingDirectory=/opt/claper +PrivateTmp=true +PrivateDevices=true +ProtectHome=true +ProtectSystem=strict +Restart=on-failure +RestartSec=30s +ReadWritePaths=/opt/claper + +[Install] +WantedBy=multi-user.target diff --git a/ressources/claper/rootfs/DEBIAN/conffiles b/ressources/claper/rootfs/DEBIAN/conffiles new file mode 100644 index 0000000..61c6790 --- /dev/null +++ b/ressources/claper/rootfs/DEBIAN/conffiles @@ -0,0 +1 @@ +/etc/default/claper diff --git a/ressources/claper/rootfs/DEBIAN/control b/ressources/claper/rootfs/DEBIAN/control new file mode 100644 index 0000000..365697d --- /dev/null +++ b/ressources/claper/rootfs/DEBIAN/control @@ -0,0 +1,8 @@ +Package: claper +Version: %VERSION% +Section: contrib +Priority: optional +Architecture: all +Depends: inotify-tools, erlang-base, erlang-syntax-tools, erlang-xmerl +Maintainer: Thomas Legay +Description: claper diff --git a/ressources/claper/rootfs/DEBIAN/postinst b/ressources/claper/rootfs/DEBIAN/postinst new file mode 100755 index 0000000..9b087ea --- /dev/null +++ b/ressources/claper/rootfs/DEBIAN/postinst @@ -0,0 +1,5 @@ +#!/bin/bash + +id claper &> /dev/null || useradd claper -r -s /bin/false -d /opt/claper + +chown -R claper:claper /opt/claper