From 1ee6628d40f554eb4b66c0377cc5fe7581c0468e Mon Sep 17 00:00:00 2001 From: Larry Ogrodnek Date: Fri, 29 Mar 2024 17:48:23 -0400 Subject: [PATCH] take 2 on slimming down example image --- Dockerfile | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/Dockerfile b/Dockerfile index 211c7c5..d069130 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,18 +1,26 @@ -FROM python:3.9-alpine +FROM python:3.11-alpine as build -# TODO don't need gcc on the final image, but need it for poetry install RUN apk add build-base libffi-dev +RUN pip install poetry +ENV POETRY_NO_INTERACTION=1 \ + POETRY_VIRTUALENVS_IN_PROJECT=1 \ + POETRY_VIRTUALENVS_CREATE=1 \ + PYTHONUNBUFFERED=1 -ENV PYTHONUNBUFFERED 1 - WORKDIR /app +COPY . . + +WORKDIR /app/examples +RUN poetry install --no-root --only main --no-cache -RUN pip3 install poetry +FROM python:3.11-alpine as runtime -COPY . . +ENV VIRTUAL_ENV=/app/examples/.venv \ + PATH="/app/examples/.venv/bin:$PATH" + +COPY --from=build /app /app WORKDIR /app/examples -RUN poetry install --no-root --only main -CMD [ "poetry", "run", "uvicorn", "--host", "0.0.0.0", "examples.app:app" ] +CMD [ "uvicorn", "--host", "0.0.0.0", "examples.app:app" ]