Skip to content

Commit 08ac4e2

Browse files
authored
Merge pull request #3 from p0lycarpio/develop
chore: s6 init scripts and user permissions
2 parents f6aeea4 + 5de5d6b commit 08ac4e2

File tree

20 files changed

+55
-23
lines changed

20 files changed

+55
-23
lines changed

.env.sample

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
PUID=1000
2+
PGID=1000
13
WEBHOOK_URL=https://discord.com/api/webhooks/abc
24
CRON=0 20 * * *
35
TMDB_TOKEN=

Dockerfile

+18-9
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
FROM alpine:3.19 AS rootfs-stage
22

3-
ARG S6_OVERLAY_VERSION="3.1.6.0"
3+
ARG S6_OVERLAY_VERSION="3.1.6.2"
44
ARG TARGETPLATFORM
55

66
RUN apk add --no-cache \
@@ -38,14 +38,23 @@ COPY --from=rootfs-stage /root-out/ /
3838
ENV S6_CMD_WAIT_FOR_SERVICES_MAXTIME=0 \
3939
PYTHONDONTWRITEBYTECODE=1
4040

41-
# install packages
42-
RUN apk add --no-cache \
43-
alpine-release \
44-
bash \
45-
ca-certificates \
46-
coreutils \
47-
tzdata && \
48-
rm -rf /tmp/*
41+
RUN \
42+
echo "**** install runtime packages ****" && \
43+
apk add --no-cache \
44+
alpine-release \
45+
bash \
46+
ca-certificates \
47+
coreutils \
48+
shadow \
49+
tzdata && \
50+
echo "**** create abc user and create /data folder ****" && \
51+
groupmod -g 1000 users && \
52+
useradd -u 911 -U -d /config -s /bin/false abc && \
53+
usermod -G users abc && \
54+
mkdir -p /data \
55+
echo "**** cleanup ****" && \
56+
rm -rf \
57+
/tmp/*
4958

5059
COPY requirements.txt /app/
5160
RUN pip3 install --no-cache-dir -r requirements.txt

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ Variables in **bold** are required.
5050
- SERVICES: filter for streaming services separated by comma. Example: `Canal+,Disney Plus,Netflix`
5151
- TZ : timezone. Default : `UTC`
5252
- LOGLEVEL stdout verbosity. Default to `INFO`
53+
- PUID/PGID: used for Docker volume permissions. Default : `911`
5354

5455
### Notification variables
5556

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/usr/bin/with-contenv bash
2+
# shellcheck shell=bash
3+
4+
cd /app || exit
5+
s6-setuidgid abc python3 -m tmdb_notifier
File renamed without changes.
+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/etc/s6-overlay/s6-rc.d/app-firstrun/run

etc/s6-overlay/s6-rc.d/cron/run

-8
This file was deleted.
+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/usr/bin/with-contenv bash
2+
# shellcheck shell=bash
3+
4+
PUID=${PUID:-911}
5+
PGID=${PGID:-911}
6+
7+
groupmod -o -g "$PGID" abc >/dev/null 2>&1
8+
usermod -o -u "$PUID" abc >/dev/null 2>&1
9+
10+
chown abc:abc /data
+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
oneshot
+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/etc/s6-overlay/s6-rc.d/init-adduser/run

etc/s6-overlay/s6-rc.d/run-app/run

-4
This file was deleted.

etc/s6-overlay/s6-rc.d/run-app/up

-1
This file was deleted.

etc/s6-overlay/s6-rc.d/svc-cron/run

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/usr/bin/with-contenv bash
2+
# shellcheck shell=bash
3+
4+
# get cron expression from tmdb_notifier cli
5+
cd /app || exit
6+
CRON=$(s6-setuidgid abc python3 -m tmdb_notifier cron)
7+
8+
# append cron job to user
9+
echo "${CRON} cd /app && python3 -m tmdb_notifier" > /data/crontab
10+
11+
# set permissions and import user crontabs
12+
chown abc:abc /data/crontab
13+
crontab -u abc /data/crontab
14+
15+
exec /usr/sbin/crond -f -S -l 5
File renamed without changes.

etc/s6-overlay/s6-rc.d/user/contents.d/app-firstrun

Whitespace-only changes.

etc/s6-overlay/s6-rc.d/user/contents.d/init-adduser

Whitespace-only changes.

etc/s6-overlay/s6-rc.d/user/contents.d/svc-cron

Whitespace-only changes.

tmdb_notifier/__main__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
changes += 1
5757

5858
logger.info(
59-
f"{nb} movies processed. {watchlist_diff} watchlist changes, {changes} movies with new providers and {nb-changes} non-updated.\n"
59+
f"{nb} movies processed. {watchlist_diff} watchlist changes, {changes} movies with new providers and {nb-changes} non-updated."
6060
)
6161
db.cleanup()
6262
db.close()

0 commit comments

Comments
 (0)