From c0e48ec21130aa1628350daf9fc1ab0f88e1452c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arturo=20Filast=C3=B2?= Date: Thu, 18 Jan 2024 15:48:22 +0100 Subject: [PATCH] Add Dockerfile to build dataapi --- api/fastapi/Dockerfile | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 api/fastapi/Dockerfile diff --git a/api/fastapi/Dockerfile b/api/fastapi/Dockerfile new file mode 100644 index 00000000..c42b038b --- /dev/null +++ b/api/fastapi/Dockerfile @@ -0,0 +1,28 @@ +# Python builder +# Produced a virtualenv with all the deps good to go + +# TODO(art): upgrade to bookworm (blocked by this +# https://github.com/actions/setup-python/issues/721) or stop using debian to +# have more recent base OS +FROM python:3.11-bullseye as py-build + +RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \ + && apt-get -y install --no-install-recommends python3 python3-dev + +RUN curl -sSL https://install.python-poetry.org | POETRY_HOME=/opt/poetry python3 - + +COPY . /app +WORKDIR /app +ENV PATH=/opt/poetry/bin:$PATH +RUN poetry config virtualenvs.in-project true && poetry install --no-interaction --no-ansi + +### Actual image running on the host +FROM python:3.11-bullseye + +ENV PYTHONDONTWRITEBYTECODE 1 +ENV PYTHONUNBUFFERED 1 + +COPY --from=py-build /app /app +WORKDIR /app +CMD ["/app/.venv/bin/uvicorn", "dataapi.main:app", "--host", "0.0.0.0", "--port", "80"] +EXPOSE 80