diff options
| author | Jan T <jan@jantuomi.fi> | 2025-08-26 11:24:50 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-08-26 11:24:50 +0000 |
| commit | c7598aa23c5cfbacbb167862032694c136fd598f (patch) | |
| tree | f089c6881a65c6e53992bcd4f546c11d2c691cb2 | |
| parent | 548f34f599d0742998c71e215afb28258ee31c27 (diff) | |
| parent | 038b3ae298aefa179cdcb21c881fa5350cf92cb7 (diff) | |
Merge pull request #2 from onnilampi/main
Containerize application and manage it with systemd
| -rw-r--r-- | .gitignore | 2 | ||||
| -rw-r--r-- | Containerfile | 11 | ||||
| -rwxr-xr-x | deploy_services.sh | 13 | ||||
| -rw-r--r-- | src/index.ts | 2 | ||||
| -rw-r--r-- | veetibot.build | 6 | ||||
| -rw-r--r-- | veetibot.container | 16 |
6 files changed, 49 insertions, 1 deletions
@@ -2,3 +2,5 @@ downloads/ node_modules/ .env dist/ +creds +IG_CREDS diff --git a/Containerfile b/Containerfile new file mode 100644 index 0000000..2ca7692 --- /dev/null +++ b/Containerfile @@ -0,0 +1,11 @@ +FROM fedora:latest +RUN dnf install -y npm nodejs tsc yt-dlp +RUN groupadd veetibot && useradd -g veetibot veetibot +RUN mkdir /veetibot && chown -R veetibot:veetibot veetibot +WORKDIR veetibot +COPY src src +COPY package.json . +COPY tsconfig.json . +RUN chown -R veetibot:veetibot ./ +USER veetibot +RUN npm install && npm install puppeteer && npm run build diff --git a/deploy_services.sh b/deploy_services.sh new file mode 100755 index 0000000..9549ed2 --- /dev/null +++ b/deploy_services.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +# Script deploys the quadlet files to the user specific directories and lets systemd build the service files. +# Finally, it copies the generated service file into a static location and enables it. + +set -euxo pipefail + +export XDG_RUNTIME_DIR="/run/user/$(id -u)" +cp veetibot.build /home/slack-veetibot/.config/containers/systemd/ +cp veetibot.container /home/slack-veetibot/.config/containers/systemd/ +systemctl --user daemon-reload +cp /run/user/1005/systemd/generator/veetibot.service /home/slack-veetibot/.config/systemd/user +systemctl --user enable veetibot diff --git a/src/index.ts b/src/index.ts index 0615cd7..e2254e7 100644 --- a/src/index.ts +++ b/src/index.ts @@ -36,7 +36,7 @@ app.command("/veeti", async ({ command, ack, respond, client }) => { return; } - console.log("Received command: /veeti", command.text); + console.log("Received command: /veeti", command.text, " from ", command.user_name); const cmdText = command.text.trim(); const cmdParts = cmdText.split(" "); const url = cmdParts[0]; diff --git a/veetibot.build b/veetibot.build new file mode 100644 index 0000000..c54646a --- /dev/null +++ b/veetibot.build @@ -0,0 +1,6 @@ +[Unit] +Description=veetibot build service + +[Build] +SetWorkingDirectory=/home/slack-veetibot/veetibot +ImageTag=veetibot:latest diff --git a/veetibot.container b/veetibot.container new file mode 100644 index 0000000..c9307c3 --- /dev/null +++ b/veetibot.container @@ -0,0 +1,16 @@ +[Unit] +Description=veetibot + +[Service] +Restart=always +RuntimeMaxSec=1d + +[Container] +Image=veetibot.build +Exec=npm start +Volume=/home/slack-veetibot/veetibot/.env:/veetibot/.env:ro +Volume=/home/slack-veetibot/veetibot/IG_CREDS:/veetibot/IG_CREDS:ro +Volume=/home/slack-veetibot/.config/chromium:/home/veetibot/.config/chromium:ro,U + +[Install] +WantedBy=default.target |
