refactor(auth): 优化 Dockerfile 构建过程以利用缓存
先复制依赖文件并安装以充分利用 Docker 构建缓存,再将不常变化的 swagger-ui 静态文件和经常变化的应用代码分开复制
This commit is contained in:
parent
e9ef32a215
commit
1427cf4884
@ -2,13 +2,16 @@ FROM python:3.13-slim
|
|||||||
|
|
||||||
WORKDIR /home/booksystem/auth
|
WORKDIR /home/booksystem/auth
|
||||||
|
|
||||||
|
# 先复制依赖文件并安装,充分利用 Docker 构建缓存
|
||||||
COPY requirements.txt .
|
COPY requirements.txt .
|
||||||
RUN pip install --no-cache-dir -r requirements.txt -i https://mirrors.aliyun.com/pypi/simple/
|
RUN pip install --no-cache-dir -r requirements.txt -i https://mirrors.aliyun.com/pypi/simple/
|
||||||
|
|
||||||
COPY . .
|
# 复制 swagger-ui 静态文件(不常变化)
|
||||||
|
|
||||||
COPY swagger-ui /home/booksystem/swagger-ui
|
COPY swagger-ui /home/booksystem/swagger-ui
|
||||||
|
|
||||||
|
# 最后复制应用代码(经常变化)
|
||||||
|
COPY . .
|
||||||
|
|
||||||
EXPOSE 8000
|
EXPOSE 8000
|
||||||
|
|
||||||
CMD ["python", "main.py"]
|
CMD ["python", "main.py"]
|
||||||
Loading…
Reference in New Issue
Block a user