-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
32 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,4 @@ | ||
.git | ||
.github | ||
tests/ | ||
.deploy_tmp_path |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,32 @@ | ||
# 基于Python3.9 alpine镜像 | ||
FROM python:3.9.17-alpine3.18 | ||
# 第一阶段:安装GCC | ||
FROM python:3.12.1-alpine as gcc_installer | ||
|
||
# 安装GCC | ||
RUN apk add --no-cache gcc musl-dev | ||
|
||
# 第二阶段:安装Python依赖 | ||
FROM gcc_installer as requirements_installer | ||
|
||
# 设置工作目录 | ||
WORKDIR /app | ||
|
||
# 将源代码复制到Docker镜像中 | ||
COPY ./LrcApi /app | ||
# 只复制 requirements.txt,充分利用 Docker 缓存层 | ||
COPY ./LrcApi/requirements.txt /app/ | ||
|
||
# 安装Python依赖 | ||
RUN pip install --no-user --prefix=/install -r requirements.txt | ||
|
||
# 第三阶段:运行环境 | ||
FROM python:3.12.1-alpine | ||
|
||
# 安装Python项目依赖 | ||
RUN pip install -r /app/requirements.txt | ||
# 设置工作目录 | ||
WORKDIR /app | ||
|
||
# 复制Python依赖 | ||
COPY --from=requirements_installer /install /usr/local | ||
|
||
# 复制项目代码 | ||
COPY ./LrcApi /app | ||
|
||
# 设置启动命令 | ||
CMD ["python", "/app/app.py"] | ||
CMD ["python", "/app/app.py"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters