feat(server): 添加pip镜像源配置支持

添加清华PyPI镜像源配置选项到环境变量文件,包括
PIP_INDEX_URL、PIP_TRUSTED_HOST和PIP_DEFAULT_TIMEOUT参数,
用于加速Docker构建过程中的包安装速度。

在docker-compose.yml中将这些参数作为构建参数传递给
Docker容器,并在Dockerfile中接收并设置为环境变量,
同时移除pip install的--no-cache-dir参数以利用缓存。
This commit is contained in:
2026-05-09 17:44:22 +08:00
parent 3df8fcacbc
commit 19db342507
3 changed files with 16 additions and 1 deletions
+3
View File
@@ -19,6 +19,9 @@ S3_SECRET_KEY=change-me-minio-password
S3_BUCKET=ciyuan-viewfinder
# Server
PIP_INDEX_URL=https://pypi.tuna.tsinghua.edu.cn/simple
PIP_TRUSTED_HOST=pypi.tuna.tsinghua.edu.cn
PIP_DEFAULT_TIMEOUT=120
DATABASE_URL=postgresql+asyncpg://shiran:change-me-postgres-password@postgres:5432/ciyuan_viewfinder
DATABASE_URL_SYNC=postgresql://shiran:change-me-postgres-password@postgres:5432/ciyuan_viewfinder
SECRET_KEY=change-me-before-production
+4
View File
@@ -59,6 +59,10 @@ services:
server:
build:
context: ./server
args:
PIP_INDEX_URL: "${PIP_INDEX_URL}"
PIP_TRUSTED_HOST: "${PIP_TRUSTED_HOST}"
PIP_DEFAULT_TIMEOUT: "${PIP_DEFAULT_TIMEOUT}"
container_name: ciyuan-server
environment:
DATABASE_URL: "${DATABASE_URL}"
+9 -1
View File
@@ -4,10 +4,18 @@ ENV PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1 \
PIP_NO_CACHE_DIR=1
ARG PIP_INDEX_URL
ARG PIP_TRUSTED_HOST
ARG PIP_DEFAULT_TIMEOUT=120
ENV PIP_INDEX_URL=${PIP_INDEX_URL} \
PIP_TRUSTED_HOST=${PIP_TRUSTED_HOST} \
PIP_DEFAULT_TIMEOUT=${PIP_DEFAULT_TIMEOUT}
WORKDIR /app
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
RUN pip install -r requirements.txt
COPY . .