Skip to content

Commit 44a3371

Browse files
committed
feat: add kometa and image maid
1 parent ba4364c commit 44a3371

File tree

17 files changed

+367
-2
lines changed

17 files changed

+367
-2
lines changed

.github/workflows/ci-cd.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,11 @@ jobs:
5858
while read -r channel
5959
do
6060
change="$(jo app="$app" channel="$channel")"
61-
changes_array+=($change)
61+
changes_array+=("$change")
6262
done < <(jq -r '.channels[] | .name' "./apps/$app/metadata.json")
6363
done < <(echo '${{ needs.get-changes.outputs.addedOrModifiedImages }}' | jq --raw-output -c '.[]')
6464
65-
output="$(jo -a ${changes_array[*]})"
65+
output="$(jo -a "${changes_array[@]}")"
6666
echo "changes=$output" >> "$GITHUB_OUTPUT"
6767
6868
image_list="[]"

apps/imagemaid/Dockerfile

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
FROM alpine:latest AS cloner
2+
ARG VERSION
3+
4+
RUN apk update && apk upgrade && \
5+
apk add --no-cache git
6+
7+
RUN git clone -b $VERSION https://github.com/Kometa-Team/ImageMaid.git /source
8+
9+
FROM python:3.11-slim-buster
10+
11+
ARG BRANCH_NAME=master
12+
ENV BRANCH_NAME=${BRANCH_NAME}
13+
ENV TINI_VERSION=v0.19.0
14+
ENV KOMETA_DOCKER=True
15+
16+
COPY --from=cloner /source/requirements.txt requirements.txt
17+
18+
RUN echo "**** install system packages ****" \
19+
&& apt-get update \
20+
&& apt-get upgrade -y --no-install-recommends \
21+
&& apt-get install -y tzdata --no-install-recommends \
22+
&& apt-get install -y gcc g++ libxml2-dev libxslt-dev libz-dev libjpeg62-turbo-dev zlib1g-dev wget curl \
23+
&& wget -O /tini https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini-"$(dpkg --print-architecture | awk -F- '{ print $NF }')" \
24+
&& chmod +x /tini \
25+
&& pip3 install --no-cache-dir --upgrade --requirement /requirements.txt \
26+
&& apt-get --purge autoremove gcc g++ libxml2-dev libxslt-dev libz-dev -y \
27+
&& apt-get clean \
28+
&& apt-get update \
29+
&& apt-get check \
30+
&& apt-get -f install \
31+
&& apt-get -y install tmux dialog \
32+
&& apt-get autoclean \
33+
&& rm -rf /requirements.txt /tmp/* /var/tmp/* /var/lib/apt/lists/*
34+
35+
COPY --from=cloner /source/. /
36+
37+
VOLUME /config
38+
39+
RUN mkdir -p /extra-scripts \
40+
&& chown -R 568:568 /extra-scripts \
41+
&& chmod -R 775 /extra-scripts
42+
43+
ADD --chmod=755 https://github.com/tsl0922/ttyd/releases/download/1.7.7/ttyd.x86_64 /usr/local/bin/ttyd
44+
COPY --chmod=0755 --chown=568:568 apps/ubuntu/base-entrypoint.sh /entrypoint.sh
45+
COPY --chmod=0755 --chown=568:568 apps/ubuntu/scripts /scripts
46+
COPY --chmod=0755 --chown=568:568 apps/imagemaid/root /
47+
48+
ARG user=notroot
49+
RUN groupadd -g 568 $user && useradd -d /config --create-home --uid 568 --gid 568 --shell /bin/bash $user
50+
RUN chown notroot /config
51+
USER 568
52+
WORKDIR /config
53+
ENTRYPOINT ["/entrypoint.sh"]

apps/imagemaid/ci/goss.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
# https://github.com/aelsabbahy/goss/blob/master/docs/manual.md#process
3+
process:
4+
python3:
5+
running: true

apps/imagemaid/ci/latest.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/usr/bin/env bash
2+
AUTH="Authorization: token ${GH_PAT:-${TOKEN:-}}"
3+
version=$(curl -Lsf -H "$AUTH" https://api.github.com/repos/Kometa-Team/ImageMaid/releases/latest | jq --raw-output '. | .tag_name')
4+
version="${version#*release-}"
5+
printf "%s" "${version}"

apps/imagemaid/metadata.json

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"app": "imagemaid",
3+
"base": false,
4+
"channels": [
5+
{
6+
"name": "main",
7+
"platforms": [
8+
"linux/amd64"
9+
],
10+
"stable": true,
11+
"tests": {
12+
"enabled": false,
13+
"type": "web"
14+
}
15+
}
16+
]
17+
}

apps/imagemaid/root/imagemaid.sh

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
#!/bin/bash
2+
3+
if [[ -z "$IMAGEMAID_ENABLED" ]];
4+
then
5+
echo "IMAGEMAID_ENABLED env var not set, doing nothing.."
6+
sleep infinity
7+
elif [[ -z "$PLEX_TOKEN" ]];
8+
then
9+
echo "PLEX_TOKEN not set, can't continue :("
10+
sleep infinity
11+
fi
12+
13+
echo "Press any key to drop to a shell, or wait 10 seconds for a normal start..."
14+
15+
# -t 5: Timeout of 5 seconds
16+
read -s -n 1 -t 10
17+
18+
if [ $? -eq 0 ]; then
19+
echo "You pressed a key! Dropping to shell.."
20+
21+
items=(1 "Run everything now!"
22+
2 "Empty trash now"
23+
3 "Clean bundles now"
24+
4 "Optimize DB now"
25+
5 "Photo Transcoder now"
26+
6 "Run on schedule"
27+
)
28+
29+
while choice=$(dialog --title "$TITLE" \
30+
--menu "Pick your task:" 20 40 6 "${items[@]}" \
31+
2>&1 >/dev/tty)
32+
do
33+
case $choice in
34+
1) python3 /imagemaid.py
35+
read -n 1 -s -r -p "Press any key to continue"
36+
;;
37+
2) EMPTY_TRASH=true python3 -u /imagemaid.py
38+
read -n 1 -s -r -p "Press any key to continue"
39+
;;
40+
3) CLEAN_BUNDLES=true python3 -u /imagemaid.py
41+
read -n 1 -s -r -p "Press any key to continue"
42+
;;
43+
4) OPTIMIZE_DB=true python3 -u /imagemaid.py
44+
read -n 1 -s -r -p "Press any key to continue"
45+
;;
46+
5) PHOTO_TRANSCODER=true python3 -u /imagemaid.py
47+
read -n 1 -s -r -p "Press any key to continue"
48+
;;
49+
*) SCHEDULE=${SCHEDULE:-'08:00|weekly(sunday)'} python3 -u /imagemaid.py
50+
read -n 1 -s -r -p "Press any key to continue"
51+
;;
52+
esac
53+
done
54+
clear
55+
else
56+
echo "Timeout reached, running ImageMaid on schedule (${SCHEDULE:-'08:00|weekly(sunday)'})... (hit CTRL-C and then ENTER to restart)"
57+
SCHEDULE=${SCHEDULE:-'08:00|weekly(sunday)'} python3 -u /imagemaid.py
58+
fi

apps/imagemaid/root/launch-tmux.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/bash
2+
3+
tmux -f /restricted.tmux.conf new-session -A -s imagemaid /imagemaid.sh
4+
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
cat << "EOF"
6+
7+
▐▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▌
8+
▐ ▌
9+
▐ ██▓███ ██▀███ ▒█████ ███▄ ▄███▓ ██ ▄█▀ ███▄ █ ██▓ ▄████ ██░ ██ ▄▄▄█████▓ ▌
10+
▐ ▓██░ ██▒▓██ ▒ ██▒▒██▒ ██▒▓██▒▀█▀ ██▒ ██▄█▒ ██ ▀█ █ ▓██▒ ██▒ ▀█▒▓██░ ██▒▓ ██▒ ▓▒ ▌
11+
▐ ▓██░ ██▓▒▓██ ░▄█ ▒▒██░ ██▒▓██ ▓██░▓███▄░ ▓██ ▀█ ██▒▒██▒▒██░▄▄▄░▒██▀▀██░▒ ▓██░ ▒░ ▌
12+
▐ ▒██▄█▓▒ ▒▒██▀▀█▄ ▒██ ██░▒██ ▒██ ▓██ █▄ ▓██▒ ▐▌██▒░██░░▓█ ██▓░▓█ ░██ ░ ▓██▓ ░ ▌
13+
▐ ▒██▒ ░ ░░██▓ ▒██▒░ ████▓▒░▒██▒ ░██▒▒██▒ █▄▒██░ ▓██░░██░░▒▓███▀▒░▓█▒░██▓ ▒██▒ ░ ▌
14+
▐ ▒▓▒░ ░ ░░ ▒▓ ░▒▓░░ ▒░▒░▒░ ░ ▒░ ░ ░▒ ▒▒ ▓▒░ ▒░ ▒ ▒ ░▓ ░▒ ▒ ▒ ░░▒░▒ ▒ ░░ ▌
15+
▐ ░▒ ░ ░▒ ░ ▒░ ░ ▒ ▒░ ░ ░ ░░ ░▒ ▒░░ ░░ ░ ▒░ ▒ ░ ░ ░ ▒ ░▒░ ░ ░ ▌
16+
▐ ░░ ░░ ░ ░ ░ ░ ▒ ░ ░ ░ ░░ ░ ░ ░ ░ ▒ ░░ ░ ░ ░ ░░ ░ ░ ▌
17+
▐ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ▌
18+
▐ ▌
19+
▐ ImageMaid ▌
20+
▐▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▌
21+
22+
EOF
23+
24+
tmux -f /restricted.tmux.conf new-session -x 80 -y 24 -A -d -s imagemaid /imagemaid.sh
25+
26+
ttyd -p 3001 -W \
27+
-t titleFixed='ImageMaid | iPromKnight' \
28+
-t 'theme={"background": "#1c1c1c", "brightGreen": "#585858", "blue": "#0087ff", "black": "#262626", "brightBlack": "#1c1c1c", "brightBlue": "#808080", "brightCyan": "#8a8a8a", "brightMagenta": "#5f5faf", "brightRed": "#d75f00", "brightWhite": "#ffffd7", "brightYellow": "#626262", "cyan": "#00afaf", "green": "#5f8700", "magenta": "#af005f", "red": "#d70000", "white": "#e4e4e4", "yellow": "#af8700"}' \
29+
-t drawBoldTextInBrightColors=false \
30+
/launch-tmux.sh
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Always launch PD
2+
set -g default-command "/imagemaid.sh"
3+
4+
# "lock down" tmux
5+
unbind C-b
6+
unbind %
7+
unbind '"'
8+
unbind c
9+
set -g mouse off
10+
11+
# Disable status bar
12+
set -g status off
13+
14+
# Disable special characters on scrolling
15+
set -g terminal-overrides 'xterm*:smcup@:rmcup@'
16+
17+
# resize as requested
18+
# set -g window-size latest
19+
setw -g aggressive-resize on

apps/kometa/Dockerfile

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
FROM alpine:latest AS cloner
2+
ARG VERSION
3+
4+
RUN apk update && apk upgrade && \
5+
apk add --no-cache git
6+
7+
RUN git clone -b $VERSION https://github.com/Kometa-Team/Kometa.git /source
8+
9+
FROM python:3.11-slim-buster
10+
11+
ARG BRANCH_NAME=master
12+
ENV BRANCH_NAME=${BRANCH_NAME}
13+
ENV TINI_VERSION=v0.19.0
14+
ENV KOMETA_DOCKER=True
15+
16+
COPY --from=cloner /source/requirements.txt requirements.txt
17+
18+
RUN echo "**** install system packages ****" \
19+
&& apt-get update \
20+
&& apt-get upgrade -y --no-install-recommends \
21+
&& apt-get install -y tzdata --no-install-recommends \
22+
&& apt-get install -y gcc g++ libxml2-dev libxslt-dev libz-dev libjpeg62-turbo-dev zlib1g-dev wget curl \
23+
&& wget -O /tini https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini-"$(dpkg --print-architecture | awk -F- '{ print $NF }')" \
24+
&& chmod +x /tini \
25+
&& pip3 install --no-cache-dir --upgrade --requirement /requirements.txt \
26+
&& apt-get --purge autoremove gcc g++ libxml2-dev libxslt-dev libz-dev -y \
27+
&& apt-get clean \
28+
&& apt-get update \
29+
&& apt-get check \
30+
&& apt-get -f install \
31+
&& apt-get -y install tmux dialog \
32+
&& apt-get autoclean \
33+
&& rm -rf /requirements.txt /tmp/* /var/tmp/* /var/lib/apt/lists/*
34+
35+
COPY --from=cloner /source/. /
36+
37+
RUN mkdir -p /extra-scripts \
38+
&& chown -R 568:568 /extra-scripts \
39+
&& chmod -R 775 /extra-scripts
40+
41+
ADD --chmod=0755 https://github.com/tsl0922/ttyd/releases/download/1.7.7/ttyd.x86_64 /usr/local/bin/ttyd
42+
COPY --chmod=0755 --chown=568:568 apps/ubuntu/base-entrypoint.sh /entrypoint.sh
43+
COPY --chmod=0755 --chown=568:568 apps/ubuntu/scripts /scripts
44+
COPY --chmod=0755 --chown=568:568 apps/kometa/root /
45+
46+
VOLUME /config
47+
48+
ARG user=notroot
49+
RUN groupadd -g 568 $user && useradd --create-home --uid 568 --gid 568 --shell /bin/bash $user
50+
RUN chown notroot /config
51+
USER 568
52+
53+
ENTRYPOINT ["/entrypoint.sh"]

0 commit comments

Comments
 (0)