mirror of
https://github.com/harry0703/MoneyPrinterTurbo.git
synced 2026-02-21 08:27:22 +08:00
enhancement: Optimize Dockerfile for China-friendly builds with prioritized domestic mirrors and fallback to global sources.
This commit is contained in:
parent
6cb5f23487
commit
b8c57f0088
46
Dockerfile
46
Dockerfile
@ -9,12 +9,40 @@ RUN chmod 777 /MoneyPrinterTurbo
|
|||||||
|
|
||||||
ENV PYTHONPATH="/MoneyPrinterTurbo"
|
ENV PYTHONPATH="/MoneyPrinterTurbo"
|
||||||
|
|
||||||
# Install system dependencies
|
# Install system dependencies with domestic mirrors first for stability
|
||||||
RUN apt-get update && apt-get install -y \
|
RUN echo "deb http://mirrors.aliyun.com/debian bullseye main" > /etc/apt/sources.list && \
|
||||||
git \
|
echo "deb http://mirrors.aliyun.com/debian-security bullseye-security main" >> /etc/apt/sources.list && \
|
||||||
imagemagick \
|
( \
|
||||||
ffmpeg \
|
for i in 1 2 3; do \
|
||||||
&& rm -rf /var/lib/apt/lists/*
|
echo "Attempt $i: Using Aliyun mirror"; \
|
||||||
|
apt-get update && apt-get install -y --no-install-recommends \
|
||||||
|
git \
|
||||||
|
imagemagick \
|
||||||
|
ffmpeg && break || \
|
||||||
|
echo "Attempt $i failed, retrying..."; \
|
||||||
|
if [ $i -eq 3 ]; then \
|
||||||
|
echo "Aliyun mirror failed, switching to Tsinghua mirror"; \
|
||||||
|
sed -i 's/mirrors.aliyun.com/mirrors.tuna.tsinghua.edu.cn/g' /etc/apt/sources.list && \
|
||||||
|
sed -i 's/mirrors.aliyun.com\/debian-security/mirrors.tuna.tsinghua.edu.cn\/debian-security/g' /etc/apt/sources.list && \
|
||||||
|
( \
|
||||||
|
apt-get update && apt-get install -y --no-install-recommends \
|
||||||
|
git \
|
||||||
|
imagemagick \
|
||||||
|
ffmpeg || \
|
||||||
|
( \
|
||||||
|
echo "Tsinghua mirror failed, switching to default Debian mirror"; \
|
||||||
|
sed -i 's/mirrors.tuna.tsinghua.edu.cn/deb.debian.org/g' /etc/apt/sources.list && \
|
||||||
|
sed -i 's/mirrors.tuna.tsinghua.edu.cn\/debian-security/security.debian.org/g' /etc/apt/sources.list; \
|
||||||
|
apt-get update && apt-get install -y --no-install-recommends \
|
||||||
|
git \
|
||||||
|
imagemagick \
|
||||||
|
ffmpeg; \
|
||||||
|
); \
|
||||||
|
); \
|
||||||
|
fi; \
|
||||||
|
sleep 5; \
|
||||||
|
done \
|
||||||
|
) && rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
# Fix security policy for ImageMagick
|
# Fix security policy for ImageMagick
|
||||||
RUN sed -i '/<policy domain="path" rights="none" pattern="@\*"/d' /etc/ImageMagick-6/policy.xml
|
RUN sed -i '/<policy domain="path" rights="none" pattern="@\*"/d' /etc/ImageMagick-6/policy.xml
|
||||||
@ -22,8 +50,10 @@ RUN sed -i '/<policy domain="path" rights="none" pattern="@\*"/d' /etc/ImageMagi
|
|||||||
# Copy only the requirements.txt first to leverage Docker cache
|
# Copy only the requirements.txt first to leverage Docker cache
|
||||||
COPY requirements.txt ./
|
COPY requirements.txt ./
|
||||||
|
|
||||||
# Install Python dependencies
|
# Install Python dependencies with domestic mirrors first and retry logic
|
||||||
RUN pip install --no-cache-dir -r requirements.txt
|
RUN pip install --no-cache-dir -i https://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com --retries 3 --timeout 60 -r requirements.txt || \
|
||||||
|
pip install --no-cache-dir -i https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple/ --trusted-host mirrors.tuna.tsinghua.edu.cn --retries 3 --timeout 60 -r requirements.txt || \
|
||||||
|
pip install --no-cache-dir --retries 3 --timeout 60 -r requirements.txt
|
||||||
|
|
||||||
# Now copy the rest of the codebase into the image
|
# Now copy the rest of the codebase into the image
|
||||||
COPY . .
|
COPY . .
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user