mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-09-04 23:17:20 +08:00
fix(docker): fuck ai bugs
This commit is contained in:
+35
-19
@@ -1,10 +1,13 @@
|
|||||||
# builder 阶段:完成所有编译、下载和准备工作
|
# builder 阶段:完成所有编译、下载和准备工作
|
||||||
FROM python:3.12.8-slim-bookworm AS builder
|
FROM python:3.12.8-slim-bookworm AS base
|
||||||
|
|
||||||
|
FROM base AS builder
|
||||||
|
|
||||||
# 设置环境变量
|
# 设置环境变量
|
||||||
ENV LANG="C.UTF-8" \
|
ENV LANG="C.UTF-8" \
|
||||||
TZ="Asia/Shanghai" \
|
TZ="Asia/Shanghai" \
|
||||||
VENV_PATH="/opt/venv"
|
VENV_PATH="/opt/venv"
|
||||||
|
|
||||||
ENV PATH="${VENV_PATH}/bin:${PATH}"
|
ENV PATH="${VENV_PATH}/bin:${PATH}"
|
||||||
|
|
||||||
# 安装系统构建依赖
|
# 安装系统构建依赖
|
||||||
@@ -17,39 +20,35 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
|
|||||||
wget \
|
wget \
|
||||||
&& \
|
&& \
|
||||||
if [ "$(uname -m)" = "x86_64" ]; \
|
if [ "$(uname -m)" = "x86_64" ]; \
|
||||||
then ln -s /usr/lib/x86_64-linux-musl/libc.so /lib/libc.musl-x86_64.so.1; \
|
then ln -s /usr/lib/x86_64-linux-musl/libc.so /lib/libc.musl-x86_64.so.1; \
|
||||||
elif [ "$(uname -m)" = "aarch64" ]; \
|
elif [ "$(uname -m)" = "aarch64" ]; \
|
||||||
then ln -s /usr/lib/aarch64-linux-musl/libc.so /lib/libc.musl-aarch64.so.1; \
|
then ln -s /usr/lib/aarch64-linux-musl/libc.so /lib/libc.musl-aarch64.so.1; \
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# 安装 Python 构建依赖并创建虚拟环境
|
# 安装 Python 构建依赖并创建虚拟环境
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
COPY ../requirements.in requirements.in
|
COPY requirements.in requirements.in
|
||||||
RUN python3 -m venv ${VENV_PATH} \
|
RUN python3 -m venv ${VENV_PATH} \
|
||||||
&& pip install --upgrade pip \
|
&& pip install --upgrade pip \
|
||||||
&& pip install Cython pip-tools \
|
&& pip install Cython pip-tools \
|
||||||
&& pip-compile requirements.in \
|
&& pip-compile requirements.in \
|
||||||
&& pip install -r requirements.txt
|
&& pip install -r requirements.txt
|
||||||
|
|
||||||
# 3. 下载外部资源
|
# 复制全部源码和下载资源
|
||||||
COPY ./version.py .
|
COPY . .
|
||||||
RUN mkdir -p /app/app/plugins /app/app/helper /public \
|
RUN FRONTEND_VERSION=$(sed -n "s/^FRONTEND_VERSION\s*=\s*'\([^']*\)'/\1/p" /app/version.py) \
|
||||||
&& 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 / - \
|
||||||
&& curl -sL "https://github.com/jxxghp/MoviePilot-Frontend/releases/download/${FRONTEND_VERSION}/dist.zip" | busybox unzip -d / - && mv /dist /public \
|
&& mv /dist /public \
|
||||||
&& curl -sL "https://github.com/jxxghp/MoviePilot-Plugins/archive/refs/heads/main.zip" | busybox unzip -d /tmp - \
|
&& 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/ \
|
&& 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)}' | \
|
&& 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 \
|
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 - \
|
&& 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/ \
|
&& mv -f /tmp/MoviePilot-Resources-main/resources.v2/* /app/app/helper/
|
||||||
&& rm -rf /tmp/*
|
|
||||||
|
|
||||||
# 复制项目的全部代码
|
|
||||||
COPY .. .
|
|
||||||
|
|
||||||
|
|
||||||
# final 阶段: 安装运行时依赖和配置最终镜像
|
# final 阶段: 安装运行时依赖和配置最终镜像
|
||||||
FROM python:3.12.8-slim-bookworm AS final
|
FROM base AS final
|
||||||
|
|
||||||
# 设置环境变量
|
# 设置环境变量
|
||||||
ENV LANG="C.UTF-8" \
|
ENV LANG="C.UTF-8" \
|
||||||
@@ -62,18 +61,20 @@ ENV LANG="C.UTF-8" \
|
|||||||
PGID=0 \
|
PGID=0 \
|
||||||
UMASK=000 \
|
UMASK=000 \
|
||||||
VENV_PATH="/opt/venv"
|
VENV_PATH="/opt/venv"
|
||||||
|
|
||||||
ENV PATH="${VENV_PATH}/bin:${PATH}"
|
ENV PATH="${VENV_PATH}/bin:${PATH}"
|
||||||
|
|
||||||
# 设置工作目录
|
# 设置工作目录
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
# 从 builder 阶段复制应用代码、所有已下载好的资源、虚拟环境中的依赖
|
# 从 builder 阶段复制应用代码、所有已下载好的资源、虚拟环境中的依赖
|
||||||
COPY --from=builder ${VENV_PATH} ${VENV_PATH}
|
COPY --from=builder --chmod=777 ${VENV_PATH} ${VENV_PATH}
|
||||||
COPY --from=builder /app /app
|
COPY --from=builder /app /app
|
||||||
COPY --from=builder /public /public
|
COPY --from=builder /public /public
|
||||||
|
|
||||||
# 安装最终镜像所需的运行时依赖
|
# 安装最终镜像所需的运行时依赖
|
||||||
RUN apt-get update && apt-get install -y --no-install-recommends \
|
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||||
|
musl-dev \
|
||||||
nginx \
|
nginx \
|
||||||
gettext-base \
|
gettext-base \
|
||||||
locales \
|
locales \
|
||||||
@@ -89,14 +90,29 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
|
|||||||
rsync \
|
rsync \
|
||||||
ffmpeg \
|
ffmpeg \
|
||||||
nano \
|
nano \
|
||||||
|
&& \
|
||||||
|
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 \
|
||||||
&& dpkg-reconfigure --frontend noninteractive tzdata \
|
&& dpkg-reconfigure --frontend noninteractive tzdata \
|
||||||
&& 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 \
|
&& apt-get clean \
|
||||||
&& rm -rf /var/lib/apt/lists/*
|
&& rm -rf \
|
||||||
|
/tmp/* \
|
||||||
|
/var/lib/apt/lists/* \
|
||||||
|
/var/tmp/*
|
||||||
|
|
||||||
# 安装playwright依赖
|
# 安装playwright依赖
|
||||||
RUN playwright install-deps chromium
|
RUN playwright install-deps chromium \
|
||||||
|
&& apt-get autoremove -y \
|
||||||
|
&& apt-get clean \
|
||||||
|
&& rm -rf \
|
||||||
|
/tmp/* \
|
||||||
|
/var/lib/apt/lists/* \
|
||||||
|
/var/tmp/*
|
||||||
|
|
||||||
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 \
|
||||||
|
|||||||
@@ -20,6 +20,10 @@ 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}"
|
||||||
|
|
||||||
@@ -270,4 +274,4 @@ fi
|
|||||||
|
|
||||||
# 启动后端服务
|
# 启动后端服务
|
||||||
INFO "→ 启动后端服务..."
|
INFO "→ 启动后端服务..."
|
||||||
exec dumb-init gosu moviepilot:moviepilot python3 app/main.py
|
exec dumb-init gosu moviepilot:moviepilot ${VENV_PATH}/bin/python3 app/main.py
|
||||||
|
|||||||
+1
-2
@@ -20,7 +20,7 @@ function WARN() {
|
|||||||
echo -e "${WARN} ${1}"
|
echo -e "${WARN} ${1}"
|
||||||
}
|
}
|
||||||
|
|
||||||
# 设置虚拟环境路径
|
# 设置虚拟环境路径(兼容群晖等系统必须这样配置)
|
||||||
VENV_PATH="${VENV_PATH:-/opt/venv}"
|
VENV_PATH="${VENV_PATH:-/opt/venv}"
|
||||||
export PATH="${VENV_PATH}/bin:$PATH"
|
export PATH="${VENV_PATH}/bin:$PATH"
|
||||||
|
|
||||||
@@ -122,7 +122,6 @@ function install_backend_and_download_resources() {
|
|||||||
rm -rf /plugins
|
rm -rf /plugins
|
||||||
mkdir -p /plugins
|
mkdir -p /plugins
|
||||||
cp -a /app/app/plugins/* /plugins/
|
cp -a /app/app/plugins/* /plugins/
|
||||||
cp -a /app/app/plugins/* /plugins/
|
|
||||||
rm -f /plugins/__init__.py
|
rm -f /plugins/__init__.py
|
||||||
# 备份站点资源
|
# 备份站点资源
|
||||||
INFO "→ 正在备份站点资源目录..."
|
INFO "→ 正在备份站点资源目录..."
|
||||||
|
|||||||
Reference in New Issue
Block a user