Merge pull request #19 from DDS-Derek/main

Complete the PUID and PGID settings & Optimize the image
This commit is contained in:
jxxghp 2023-07-29 08:37:45 +08:00 committed by GitHub
commit a30a41a741
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 36 additions and 9 deletions

View File

@ -1,5 +1,7 @@
FROM python:3.10.11-slim
ENV LANG="C.UTF-8" \
HOME="/moviepilot" \
TERM="xterm" \
TZ="Asia/Shanghai" \
PUID=0 \
PGID=0 \
@ -30,16 +32,33 @@ ENV LANG="C.UTF-8" \
WORKDIR "/app"
COPY . .
RUN apt-get update \
&& apt-get -y install musl-dev nginx gettext-base \
&& mkdir -p /etc/nginx \
&& apt-get -y install \
musl-dev \
nginx \
gettext-base \
locales \
procps \
gosu \
bash \
&& mkdir -p /etc/nginx ${HOME} \
&& cp -f nginx.conf /etc/nginx/nginx.template.conf \
&& groupadd -r moviepilot -g 911 \
&& useradd -r moviepilot -g moviepilot -d ${HOME} -s /bin/bash -u 911 \
&& pip install --upgrade pip \
&& pip install -r requirements.txt \
&& playwright install-deps chromium \
&& python_ver=$(python3 -V | awk '{print $2}') \
&& echo "/app/" > /usr/local/lib/python${python_ver%.*}/site-packages/app.pth \
&& echo 'fs.inotify.max_user_watches=5242880' >> /etc/sysctl.conf \
&& echo 'fs.inotify.max_user_instances=5242880' >> /etc/sysctl.conf \
&& playwright install-deps chromium \
&& rm -rf /root/.cache/
&& locale-gen zh_CN.UTF-8 \
&& apt-get autoremove -y \
&& apt-get clean -y \
&& rm -rf \
/tmp/* \
/moviepilot/.cache \
/var/lib/apt/lists/* \
/var/tmp/*
EXPOSE 3000
VOLUME ["/config"]
ENTRYPOINT [ "bash", "-c", "/app/start.sh & nginx -g 'daemon off;'" ]
ENTRYPOINT [ "/app/start.sh" ]

View File

@ -1,9 +1,17 @@
#!/bin/sh
#!/bin/bash
umask ${UMASK}
# 使用 `envsubst` 将模板文件中的 ${NGINX_PORT} 替换为实际的环境变量值
envsubst '${NGINX_PORT}' < /etc/nginx/nginx.template.conf > /etc/nginx/nginx.conf
# 更改 moviepilot userid 和 groupid
groupmod -o -g ${PGID} moviepilot
usermod -o -u ${PUID} moviepilot
# 更改文件权限
chown -R moviepilot:moviepilot ${HOME} /app /config
# 下载浏览器内核
playwright install chromium
gosu moviepilot:moviepilot playwright install chromium
# 启动前端nginx服务
nginx
# 设置后端服务权限掩码
umask ${UMASK}
# 启动后端服务
python3 app/main.py
exec gosu moviepilot:moviepilot python3 app/main.py