Move to multi stage docker builds to reduce the image size

This commit is contained in:
Christoph Reiter 2020-11-21 12:10:37 +01:00
parent 5858875f01
commit 02eae99833

View File

@ -1,4 +1,4 @@
FROM ubuntu:focal
FROM ubuntu:focal as build
RUN apt-get update && apt-get install -y \
python3 \
@ -10,7 +10,18 @@ RUN python3 -m pip install "poetry==1.1.4"
COPY . /app
WORKDIR /app
RUN poetry config virtualenvs.in-project true
RUN poetry install --no-dev
ENTRYPOINT ["poetry","run", "uvicorn", "--proxy-headers", "--host", "0.0.0.0", "--port", "80", "app:app"]
FROM ubuntu:focal
COPY --from=build /app /app
RUN apt-get update && apt-get install -y \
python3 \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /app
ENV PATH="/app/.venv/bin:$PATH"
ENTRYPOINT ["uvicorn", "--proxy-headers", "--host", "0.0.0.0", "--port", "80", "app:app"]
EXPOSE 80