Skip to content

Commit

Permalink
fix: Dockerfile
Browse files Browse the repository at this point in the history
Signed-off-by: samzong.lu <[email protected]>
  • Loading branch information
samzong committed May 17, 2024
1 parent 68a9d29 commit 37f25c6
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions Dockerfile
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"]

0 comments on commit 37f25c6

Please sign in to comment.