mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-02-02 18:22:39 +08:00
fix build
This commit is contained in:
@@ -64,10 +64,6 @@ temp/
|
|||||||
*.sqlite
|
*.sqlite
|
||||||
*.sqlite3
|
*.sqlite3
|
||||||
|
|
||||||
# Config files that should be mounted
|
|
||||||
config/
|
|
||||||
database/
|
|
||||||
|
|
||||||
# Test files
|
# Test files
|
||||||
tests/
|
tests/
|
||||||
test_*
|
test_*
|
||||||
|
|||||||
@@ -1,4 +1,57 @@
|
|||||||
FROM python:3.12.8-slim-bookworm
|
# builder 阶段:完成所有编译、下载和准备工作
|
||||||
|
FROM python:3.12.8-slim-bookworm AS builder
|
||||||
|
|
||||||
|
# 设置环境变量
|
||||||
|
ENV LANG="C.UTF-8" \
|
||||||
|
TZ="Asia/Shanghai" \
|
||||||
|
VENV_PATH="/opt/venv"
|
||||||
|
ENV PATH="${VENV_PATH}/bin:${PATH}"
|
||||||
|
|
||||||
|
# 安装系统构建依赖
|
||||||
|
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||||
|
build-essential \
|
||||||
|
musl-dev \
|
||||||
|
curl \
|
||||||
|
busybox \
|
||||||
|
jq \
|
||||||
|
wget \
|
||||||
|
&& \
|
||||||
|
if [ "$(uname -m)" = "x86_64" ]; \
|
||||||
|
then ln -s /usr/lib/x86_64-linux-musl/libc.so /lib/libc.musl-x86_64.so.1; \
|
||||||
|
elif [ "$(uname -m)" = "aarch64" ]; \
|
||||||
|
then ln -s /usr/lib/aarch64-linux-musl/libc.so /lib/libc.musl-aarch64.so.1; \
|
||||||
|
fi
|
||||||
|
|
||||||
|
# 安装 Python 构建依赖并创建虚拟环境
|
||||||
|
WORKDIR /app
|
||||||
|
COPY ../requirements.in requirements.in
|
||||||
|
RUN python3 -m venv ${VENV_PATH} \
|
||||||
|
&& pip install --upgrade pip \
|
||||||
|
&& pip install Cython pip-tools \
|
||||||
|
&& pip-compile requirements.in \
|
||||||
|
&& pip install -r requirements.txt
|
||||||
|
|
||||||
|
# 3. 下载外部资源
|
||||||
|
COPY ./version.py .
|
||||||
|
RUN mkdir -p /app/app/plugins /app/app/helper /public \
|
||||||
|
&& FRONTEND_VERSION=$(sed -n "s/^FRONTEND_VERSION\s*=\s*'\([^']*\)'/\1/p" /app/version.py) \
|
||||||
|
&& curl -sL "https://github.com/jxxghp/MoviePilot-Frontend/releases/download/${FRONTEND_VERSION}/dist.zip" | busybox unzip -d / - && mv /dist /public \
|
||||||
|
&& curl -sL "https://github.com/jxxghp/MoviePilot-Plugins/archive/refs/heads/main.zip" | busybox unzip -d /tmp - \
|
||||||
|
&& mv -f /tmp/MoviePilot-Plugins-main/plugins.v2/* /app/app/plugins/ \
|
||||||
|
&& cat /tmp/MoviePilot-Plugins-main/package.json | jq -r 'to_entries[] | select(.value.v2 == true) | .key' | awk '{print tolower($0)}' | \
|
||||||
|
while read -r i; do if [ ! -d "/app/app/plugins/$i" ]; then mv "/tmp/MoviePilot-Plugins-main/plugins/$i" "/app/app/plugins/"; else echo "跳过 $i"; fi; done \
|
||||||
|
&& curl -sL "https://github.com/jxxghp/MoviePilot-Resources/archive/refs/heads/main.zip" | busybox unzip -d /tmp - \
|
||||||
|
&& mv -f /tmp/MoviePilot-Resources-main/resources.v2/* /app/app/helper/ \
|
||||||
|
&& rm -rf /tmp/*
|
||||||
|
|
||||||
|
# 复制项目的全部代码
|
||||||
|
COPY .. .
|
||||||
|
|
||||||
|
|
||||||
|
# final 阶段: 安装运行时依赖和配置最终镜像
|
||||||
|
FROM python:3.12.8-slim-bookworm AS final
|
||||||
|
|
||||||
|
# 设置环境变量
|
||||||
ENV LANG="C.UTF-8" \
|
ENV LANG="C.UTF-8" \
|
||||||
TZ="Asia/Shanghai" \
|
TZ="Asia/Shanghai" \
|
||||||
HOME="/moviepilot" \
|
HOME="/moviepilot" \
|
||||||
@@ -9,68 +62,42 @@ ENV LANG="C.UTF-8" \
|
|||||||
PGID=0 \
|
PGID=0 \
|
||||||
UMASK=000 \
|
UMASK=000 \
|
||||||
VENV_PATH="/opt/venv"
|
VENV_PATH="/opt/venv"
|
||||||
WORKDIR "/app"
|
ENV PATH="${VENV_PATH}/bin:${PATH}"
|
||||||
|
|
||||||
# 安装系统依赖
|
# 设置工作目录
|
||||||
RUN apt-get update -y \
|
WORKDIR /app
|
||||||
&& apt-get upgrade -y \
|
|
||||||
&& apt-get -y install \
|
# 从 builder 阶段复制应用代码、所有已下载好的资源、虚拟环境中的依赖
|
||||||
musl-dev \
|
COPY --from=builder ${VENV_PATH} ${VENV_PATH}
|
||||||
nginx \
|
COPY --from=builder /app /app
|
||||||
gettext-base \
|
COPY --from=builder /public /public
|
||||||
locales \
|
|
||||||
procps \
|
# 安装最终镜像所需的运行时依赖
|
||||||
gosu \
|
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||||
bash \
|
nginx \
|
||||||
wget \
|
gettext-base \
|
||||||
curl \
|
locales \
|
||||||
busybox \
|
procps \
|
||||||
dumb-init \
|
gosu \
|
||||||
jq \
|
bash \
|
||||||
fuse3 \
|
curl \
|
||||||
rsync \
|
wget \
|
||||||
ffmpeg \
|
busybox \
|
||||||
nano \
|
dumb-init \
|
||||||
build-essential \
|
jq \
|
||||||
|
fuse3 \
|
||||||
|
rsync \
|
||||||
|
ffmpeg \
|
||||||
|
nano \
|
||||||
&& dpkg-reconfigure --frontend noninteractive tzdata \
|
&& dpkg-reconfigure --frontend noninteractive tzdata \
|
||||||
&& \
|
|
||||||
if [ "$(uname -m)" = "x86_64" ]; \
|
|
||||||
then ln -s /usr/lib/x86_64-linux-musl/libc.so /lib/libc.musl-x86_64.so.1; \
|
|
||||||
elif [ "$(uname -m)" = "aarch64" ]; \
|
|
||||||
then ln -s /usr/lib/aarch64-linux-musl/libc.so /lib/libc.musl-aarch64.so.1; \
|
|
||||||
fi \
|
|
||||||
&& curl https://rclone.org/install.sh | bash \
|
&& curl https://rclone.org/install.sh | bash \
|
||||||
&& apt-get autoremove -y \
|
&& apt-get autoremove -y \
|
||||||
&& apt-get clean -y \
|
&& apt-get clean \
|
||||||
&& rm -rf \
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
/tmp/* \
|
|
||||||
/moviepilot/.cache \
|
|
||||||
/var/lib/apt/lists/* \
|
|
||||||
/var/tmp/*
|
|
||||||
|
|
||||||
# 创建虚拟环境
|
# 安装playwright依赖
|
||||||
RUN python3 -m venv ${VENV_PATH} \
|
RUN playwright install-deps chromium
|
||||||
&& ${VENV_PATH}/bin/pip install --upgrade pip \
|
|
||||||
&& ${VENV_PATH}/bin/pip install Cython pip-tools
|
|
||||||
|
|
||||||
# 复制依赖文件并安装到虚拟环境
|
|
||||||
COPY ../requirements.in requirements.in
|
|
||||||
RUN ${VENV_PATH}/bin/pip-compile requirements.in \
|
|
||||||
&& ${VENV_PATH}/bin/pip install -r requirements.txt \
|
|
||||||
&& ${VENV_PATH}/bin/playwright install-deps chromium \
|
|
||||||
&& apt-get remove -y build-essential \
|
|
||||||
&& apt-get autoremove -y \
|
|
||||||
&& apt-get clean -y \
|
|
||||||
&& rm -rf \
|
|
||||||
/tmp/* \
|
|
||||||
/moviepilot/.cache \
|
|
||||||
/var/lib/apt/lists/* \
|
|
||||||
/var/tmp/*
|
|
||||||
|
|
||||||
# 复制应用代码
|
|
||||||
COPY .. .
|
|
||||||
|
|
||||||
# 配置nginx和其他文件
|
|
||||||
RUN cp -f /app/docker/nginx.common.conf /etc/nginx/common.conf \
|
RUN cp -f /app/docker/nginx.common.conf /etc/nginx/common.conf \
|
||||||
&& cp -f /app/docker/nginx.template.conf /etc/nginx/nginx.template.conf \
|
&& cp -f /app/docker/nginx.template.conf /etc/nginx/nginx.template.conf \
|
||||||
&& cp -f /app/docker/update.sh /usr/local/bin/mp_update.sh \
|
&& cp -f /app/docker/update.sh /usr/local/bin/mp_update.sh \
|
||||||
@@ -78,23 +105,15 @@ RUN cp -f /app/docker/nginx.common.conf /etc/nginx/common.conf \
|
|||||||
&& cp -f /app/docker/docker_http_proxy.conf /etc/nginx/docker_http_proxy.conf \
|
&& cp -f /app/docker/docker_http_proxy.conf /etc/nginx/docker_http_proxy.conf \
|
||||||
&& chmod +x /entrypoint.sh /usr/local/bin/mp_update.sh \
|
&& chmod +x /entrypoint.sh /usr/local/bin/mp_update.sh \
|
||||||
&& mkdir -p ${HOME} \
|
&& mkdir -p ${HOME} \
|
||||||
|
&& mkdir -p ${CONFIG_DIR} \
|
||||||
&& groupadd -r moviepilot -g 918 \
|
&& groupadd -r moviepilot -g 918 \
|
||||||
&& useradd -r moviepilot -g moviepilot -d ${HOME} -s /bin/bash -u 918 \
|
&& useradd -r moviepilot -g moviepilot -d ${HOME} -s /bin/bash -u 918 \
|
||||||
|
&& chown -R moviepilot:moviepilot /app ${VENV_PATH} /public ${HOME} ${CONFIG_DIR} \
|
||||||
&& python_ver=$(python3 -V | awk '{print $2}') \
|
&& python_ver=$(python3 -V | awk '{print $2}') \
|
||||||
&& echo "/app/" > ${VENV_PATH}/lib/python${python_ver%.*}/site-packages/app.pth \
|
&& echo "/app/" > ${VENV_PATH}/lib/python${python_ver%.*}/site-packages/app.pth \
|
||||||
&& echo 'fs.inotify.max_user_watches=5242880' >> /etc/sysctl.conf \
|
&& echo 'fs.inotify.max_user_watches=5242880' >> /etc/sysctl.conf \
|
||||||
&& echo 'fs.inotify.max_user_instances=5242880' >> /etc/sysctl.conf \
|
&& echo 'fs.inotify.max_user_instances=5242880' >> /etc/sysctl.conf \
|
||||||
&& locale-gen zh_CN.UTF-8 \
|
&& locale-gen zh_CN.UTF-8
|
||||||
&& FRONTEND_VERSION=$(sed -n "s/^FRONTEND_VERSION\s*=\s*'\([^']*\)'/\1/p" /app/version.py) \
|
|
||||||
&& curl -sL "https://github.com/jxxghp/MoviePilot-Frontend/releases/download/${FRONTEND_VERSION}/dist.zip" | busybox unzip -d / - \
|
|
||||||
&& mv /dist /public \
|
|
||||||
&& curl -sL "https://github.com/jxxghp/MoviePilot-Plugins/archive/refs/heads/main.zip" | busybox unzip -d /tmp - \
|
|
||||||
&& mv -f /tmp/MoviePilot-Plugins-main/plugins.v2/* /app/app/plugins/ \
|
|
||||||
&& cat /tmp/MoviePilot-Plugins-main/package.json | jq -r 'to_entries[] | select(.value.v2 == true) | .key' | awk '{print tolower($0)}' | \
|
|
||||||
while read -r i; do if [ ! -d "/app/app/plugins/$i" ]; then mv "/tmp/MoviePilot-Plugins-main/plugins/$i" "/app/app/plugins/"; else echo "跳过 $i"; fi; done \
|
|
||||||
&& curl -sL "https://github.com/jxxghp/MoviePilot-Resources/archive/refs/heads/main.zip" | busybox unzip -d /tmp - \
|
|
||||||
&& mv -f /tmp/MoviePilot-Resources-main/resources.v2/* /app/app/helper/ \
|
|
||||||
&& rm -rf /tmp/*
|
|
||||||
|
|
||||||
EXPOSE 3000
|
EXPOSE 3000
|
||||||
VOLUME [ "${CONFIG_DIR}" ]
|
VOLUME [ "${CONFIG_DIR}" ]
|
||||||
|
|||||||
@@ -20,10 +20,6 @@ function WARN() {
|
|||||||
echo -e "${WARN} ${1}"
|
echo -e "${WARN} ${1}"
|
||||||
}
|
}
|
||||||
|
|
||||||
# 设置虚拟环境路径
|
|
||||||
VENV_PATH="${VENV_PATH:-/opt/venv}"
|
|
||||||
export PATH="${VENV_PATH}/bin:$PATH"
|
|
||||||
|
|
||||||
# 校正设置目录
|
# 校正设置目录
|
||||||
CONFIG_DIR="${CONFIG_DIR:-/config}"
|
CONFIG_DIR="${CONFIG_DIR:-/config}"
|
||||||
|
|
||||||
@@ -226,8 +222,7 @@ chown -R moviepilot:moviepilot \
|
|||||||
/public \
|
/public \
|
||||||
"${CONFIG_DIR}" \
|
"${CONFIG_DIR}" \
|
||||||
/var/lib/nginx \
|
/var/lib/nginx \
|
||||||
/var/log/nginx \
|
/var/log/nginx
|
||||||
"${VENV_PATH}"
|
|
||||||
chown moviepilot:moviepilot /etc/hosts /tmp
|
chown moviepilot:moviepilot /etc/hosts /tmp
|
||||||
|
|
||||||
# 下载浏览器内核
|
# 下载浏览器内核
|
||||||
@@ -275,4 +270,4 @@ fi
|
|||||||
|
|
||||||
# 启动后端服务
|
# 启动后端服务
|
||||||
INFO "→ 启动后端服务..."
|
INFO "→ 启动后端服务..."
|
||||||
exec dumb-init gosu moviepilot:moviepilot ${VENV_PATH}/bin/python3 app/main.py
|
exec dumb-init gosu moviepilot:moviepilot python3 app/main.py
|
||||||
|
|||||||
Reference in New Issue
Block a user