Skip to content

Commit

Permalink
Merge pull request #5 from ogrodnek/optimize_docker
Browse files Browse the repository at this point in the history
use docker build stage
  • Loading branch information
ogrodnek authored Oct 25, 2023
2 parents a5ed012 + 722d743 commit 7b2fda2
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
FROM python:3.9-alpine

# TODO don't need gcc on the final image, but need it for poetry install
RUN apk add build-base libffi-dev

# --- Build Stage ---
FROM python:3.9-alpine AS builder

RUN apk add --no-cache build-base libffi-dev
ENV PYTHONUNBUFFERED 1

WORKDIR /app

RUN pip3 install poetry

RUN pip3 install --no-cache-dir poetry
COPY . .

WORKDIR /app/examples
RUN poetry install --no-root --only main

# --- Runtime Stage ---
FROM python:3.9-alpine

COPY --from=builder /usr/local/lib/python3.9/site-packages /usr/local/lib/python3.9/site-packages
COPY --from=builder /usr/local/bin /usr/local/bin
COPY --from=builder /app /app


WORKDIR /app/examples
CMD [ "poetry", "run", "uvicorn", "--host", "0.0.0.0", "examples.app:app" ]

0 comments on commit 7b2fda2

Please sign in to comment.