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:
@@ -19,6 +19,9 @@ S3_SECRET_KEY=change-me-minio-password
|
|||||||
S3_BUCKET=ciyuan-viewfinder
|
S3_BUCKET=ciyuan-viewfinder
|
||||||
|
|
||||||
# Server
|
# 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=postgresql+asyncpg://shiran:change-me-postgres-password@postgres:5432/ciyuan_viewfinder
|
||||||
DATABASE_URL_SYNC=postgresql://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
|
SECRET_KEY=change-me-before-production
|
||||||
|
|||||||
@@ -59,6 +59,10 @@ services:
|
|||||||
server:
|
server:
|
||||||
build:
|
build:
|
||||||
context: ./server
|
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
|
container_name: ciyuan-server
|
||||||
environment:
|
environment:
|
||||||
DATABASE_URL: "${DATABASE_URL}"
|
DATABASE_URL: "${DATABASE_URL}"
|
||||||
|
|||||||
+9
-1
@@ -4,10 +4,18 @@ ENV PYTHONDONTWRITEBYTECODE=1 \
|
|||||||
PYTHONUNBUFFERED=1 \
|
PYTHONUNBUFFERED=1 \
|
||||||
PIP_NO_CACHE_DIR=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
|
WORKDIR /app
|
||||||
|
|
||||||
COPY requirements.txt .
|
COPY requirements.txt .
|
||||||
RUN pip install --no-cache-dir -r requirements.txt
|
RUN pip install -r requirements.txt
|
||||||
|
|
||||||
COPY . .
|
COPY . .
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user