-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: samzong.lu <[email protected]>
- Loading branch information
Showing
1 changed file
with
15 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,23 +1,31 @@ | ||
FROM python:3.11-slim | ||
# Use a smaller base image | ||
FROM python:3.11-slim as builder | ||
|
||
LABEL maintainer="[email protected]" | ||
|
||
WORKDIR /app | ||
|
||
# 安装 Poetry | ||
# Install Poetry | ||
RUN apt-get update && apt-get install -y curl && \ | ||
curl -sSL https://install.python-poetry.org | python3 - && \ | ||
apt-get remove -y curl && apt-get autoremove -y && \ | ||
ln -s $HOME/.local/bin/poetry /usr/local/bin/poetry | ||
|
||
# 复制项目文件 | ||
# Copy project files | ||
COPY . . | ||
|
||
# 安装项目依赖 | ||
RUN poetry install --no-dev | ||
# Install project dependencies | ||
RUN poetry install --only main --no-cache --no-root | ||
|
||
|
||
# Start a new stage | ||
FROM python:3.11-slim | ||
|
||
# Copy only the necessary files from the previous stage | ||
COPY --from=builder /app . | ||
|
||
# 暴露端口 | ||
# Expose port | ||
EXPOSE 5000 | ||
|
||
# 启动项目 | ||
# Start the project | ||
CMD ["poetry", "run", "uvicorn", "main:app" ,"--host", "0.0.0.0", "--port", "5000"] |