Skip to content

Commit

Permalink
feat: optimize Dockerfile for multi-stage build and user installation…
Browse files Browse the repository at this point in the history
… of dependencies
  • Loading branch information
lakminagamage committed Dec 18, 2024
1 parent d9b6a2e commit 695a8d7
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
FROM python:3.9-slim
FROM python:3.9-slim as build
WORKDIR /app
RUN apt-get update && apt-get install -y gcc libpq-dev
COPY requirements.txt /app
RUN pip install --user -r requirements.txt

FROM python:3.9-slim
WORKDIR /app
COPY --from=build /root/.local /root/.local
ENV PATH=/root/.local/bin:$PATH
COPY . /app
RUN pip install -r requirements.txt
EXPOSE 5002
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "5002"]
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "5002"]

0 comments on commit 695a8d7

Please sign in to comment.