修复docker构建使用国内源

This commit is contained in:
oficcejo
2025-10-21 21:12:16 +08:00
parent 09ef84a881
commit 916ed5a95d
4 changed files with 471 additions and 14 deletions
+21 -12
View File
@@ -13,10 +13,12 @@ RUN echo "deb https://mirrors.aliyun.com/debian/ bookworm main" > /etc/apt/sourc
# 设置工作目录
WORKDIR /app
# 安装Node.js、中文字体和时区数据 - 使用修正版方案一
# 安装基础依赖、中文字体和时区数据
RUN apt-get update && apt-get install -y \
curl \
gnupg \
tar \
xz-utils \
ca-certificates \
fonts-noto-cjk \
fonts-wqy-zenhei \
fonts-wqy-microhei \
@@ -24,16 +26,23 @@ RUN apt-get update && apt-get install -y \
tzdata \
&& ln -snf /usr/share/zoneinfo/$TZ /etc/localtime \
&& echo $TZ > /etc/timezone \
&& curl -fsSL https://mirrors.aliyun.com/nodesource/setup_18.x | bash - \
&& apt-get install -y nodejs npm \
&& fc-cache -fv \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
# 验证安装 - 添加详细检查
RUN echo "Node.js版本:" && node --version && \
    echo "npm路径:" && which npm && \
    echo "npm版本:" && npm --version
# 安装Node.js(从淘宝镜像下载二进制包,最稳定快速的方案)
RUN NODE_VERSION=18.20.4 && \
ARCH=$(dpkg --print-architecture) && \
if [ "$ARCH" = "amd64" ]; then NODE_ARCH="x64"; \
elif [ "$ARCH" = "arm64" ]; then NODE_ARCH="arm64"; \
else NODE_ARCH="$ARCH"; fi && \
curl -fsSL https://registry.npmmirror.com/-/binary/node/v${NODE_VERSION}/node-v${NODE_VERSION}-linux-${NODE_ARCH}.tar.gz -o /tmp/node.tar.gz && \
tar -xzf /tmp/node.tar.gz -C /usr/local --strip-components=1 && \
rm /tmp/node.tar.gz && \
ln -s /usr/local/bin/node /usr/local/bin/nodejs
# 验证安装
RUN node --version && npm --version
# 配置npm使用淘宝镜像源
RUN npm config set registry https://registry.npmmirror.com/
@@ -41,10 +50,10 @@ RUN npm config set registry https://registry.npmmirror.com/
# 复制依赖文件
COPY requirements.txt .
# 安装Python依赖
RUN pip config set global.index-url https://mirrors.aliyun.com/pypi/simple/ && \
    pip config set global.trusted-host mirrors.aliyun.com && \
    pip install --no-cache-dir --default-timeout=1000 -r requirements.txt
# 安装Python依赖(使用清华源,更稳定)
RUN pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple/ && \
pip config set global.trusted-host pypi.tuna.tsinghua.edu.cn && \
pip install --no-cache-dir --default-timeout=1000 -r requirements.txt
# 复制项目文件
COPY . .