mirror of
https://github.com/EstrellaXD/Auto_Bangumi.git
synced 2026-02-03 02:04:06 +08:00
feat: from s6-overlay change to tini and su-exec
This commit is contained in:
28
Dockerfile
28
Dockerfile
@@ -1,14 +1,8 @@
|
||||
# syntax=docker/dockerfile:1
|
||||
|
||||
FROM alpine:3.18 AS APP
|
||||
FROM alpine:3.18
|
||||
|
||||
ENV S6_SERVICES_GRACETIME=30000 \
|
||||
S6_KILL_GRACETIME=60000 \
|
||||
S6_CMD_WAIT_FOR_SERVICES_MAXTIME=0 \
|
||||
S6_SYNC_DISKS=1 \
|
||||
TERM="xterm" \
|
||||
HOME="/ab" \
|
||||
LANG="C.UTF-8" \
|
||||
ENV LANG="C.UTF-8" \
|
||||
TZ=Asia/Shanghai \
|
||||
PUID=1000 \
|
||||
PGID=1000 \
|
||||
@@ -20,33 +14,29 @@ COPY backend/requirements.txt .
|
||||
RUN set -ex && \
|
||||
apk add --no-cache \
|
||||
bash \
|
||||
ca-certificates \
|
||||
coreutils \
|
||||
curl \
|
||||
jq \
|
||||
netcat-openbsd \
|
||||
procps-ng \
|
||||
python3 \
|
||||
py3-bcrypt \
|
||||
py3-pip \
|
||||
s6-overlay \
|
||||
su-exec \
|
||||
shadow \
|
||||
tini \
|
||||
tzdata && \
|
||||
python3 -m pip install --no-cache-dir --upgrade pip && \
|
||||
sed -i '/bcrypt/d' requirements.txt && \
|
||||
pip install --no-cache-dir -r requirements.txt && \
|
||||
# Add user
|
||||
mkdir -p /home/ab && \
|
||||
addgroup -S ab -g 911 && \
|
||||
adduser -S ab -G ab -h /ab -s /bin/bash -u 911 && \
|
||||
adduser -S ab -G ab -h /home/ab -s /sbin/nologin -u 911 && \
|
||||
# Clear
|
||||
rm -rf \
|
||||
/ab/.cache \
|
||||
/root/.cache \
|
||||
/tmp/*
|
||||
|
||||
COPY --chmod=755 backend/src/. .
|
||||
COPY --chmod=755 docker/ /
|
||||
COPY --chmod=755 entrypoint.sh /entrypoint.sh
|
||||
|
||||
ENTRYPOINT [ "/init" ]
|
||||
ENTRYPOINT ["tini", "-g", "--", "/entrypoint.sh"]
|
||||
|
||||
EXPOSE 7892
|
||||
VOLUME [ "/app/config" , "/app/data" ]
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
#!/usr/bin/with-contenv bash
|
||||
# shellcheck shell=bash
|
||||
|
||||
groupmod -o -g "${PGID}" ab
|
||||
usermod -o -u "${PUID}" ab
|
||||
|
||||
chown ab:ab -R /app /ab
|
||||
@@ -1 +0,0 @@
|
||||
oneshot
|
||||
@@ -1 +0,0 @@
|
||||
/etc/s6-overlay/s6-rc.d/init-fixuser/run
|
||||
@@ -1,8 +0,0 @@
|
||||
#!/usr/bin/with-contenv bash
|
||||
# shellcheck shell=bash
|
||||
|
||||
umask ${UMASK}
|
||||
|
||||
if [ -f /config/bangumi.json ]; then
|
||||
mv /config/bangumi.json /app/data/bangumi.json
|
||||
fi
|
||||
@@ -1 +0,0 @@
|
||||
oneshot
|
||||
@@ -1 +0,0 @@
|
||||
/etc/s6-overlay/s6-rc.d/init-old-compatible/run
|
||||
@@ -1,4 +0,0 @@
|
||||
#!/usr/bin/with-contenv bash
|
||||
# shellcheck shell=bash
|
||||
|
||||
pkill -f 'python3 main.py'
|
||||
@@ -1 +0,0 @@
|
||||
3
|
||||
@@ -1,16 +0,0 @@
|
||||
#!/usr/bin/with-contenv bash
|
||||
# shellcheck shell=bash
|
||||
|
||||
umask ${UMASK}
|
||||
|
||||
if [ -f /app/config/config.json ]; then
|
||||
AB_PORT=$(jq '.program.webui_port' /app/config/config.json)
|
||||
elif [ -f /app/config/config_dev.json ]; then
|
||||
AB_PORT=$(jq '.program.webui_port' /app/config/config_dev.json)
|
||||
else
|
||||
AB_PORT=7892
|
||||
fi
|
||||
|
||||
exec \
|
||||
s6-notifyoncheck -d -n 300 -w 1000 -c "nc -z localhost ${AB_PORT}" \
|
||||
cd /app s6-setuidgid ab python3 main.py
|
||||
@@ -1 +0,0 @@
|
||||
longrun
|
||||
15
entrypoint.sh
Normal file
15
entrypoint.sh
Normal file
@@ -0,0 +1,15 @@
|
||||
#!/bin/bash
|
||||
# shellcheck shell=bash
|
||||
|
||||
umask ${UMASK}
|
||||
|
||||
if [ -f /config/bangumi.json ]; then
|
||||
mv /config/bangumi.json /app/data/bangumi.json
|
||||
fi
|
||||
|
||||
groupmod -o -g "${PGID}" ab
|
||||
usermod -o -u "${PUID}" ab
|
||||
|
||||
chown ab:ab -R /app /home/ab
|
||||
|
||||
exec su-exec "${PUID}:${PGID}" python3 main.py
|
||||
Reference in New Issue
Block a user