From 39c7599a99b16bdb53356c15c79feed0e49998ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Drago=C8=99?= Date: Wed, 9 Oct 2024 15:31:54 +0200 Subject: [PATCH] Remove poetry from Dockerfile --- Dockerfile | 32 ++++++++++++++++++++------------ docker-entrypoint.sh | 2 +- 2 files changed, 21 insertions(+), 13 deletions(-) diff --git a/Dockerfile b/Dockerfile index 5de08d8..f578b97 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,10 +1,26 @@ +FROM docker.io/python:3.11 AS req + +RUN python3 -m pip install pipx && \ + python3 -m pipx ensurepath + +RUN pipx install poetry==1.8.2 && \ + pipx inject poetry poetry-plugin-export && \ + pipx run poetry config warnings.export false + +COPY ./poetry.lock ./poetry.lock +COPY ./pyproject.toml ./pyproject.toml +RUN pipx run poetry export --format requirements.txt --output requirements.txt + FROM nvidia/cuda:12.2.2-cudnn8-runtime-ubuntu22.04 -# Install ffmpeg +# Install Python & ffmpeg RUN apt-get update && \ - apt-get install -y python3-pip python3.11-dev python-is-python3 ffmpeg && \ + apt-get install -y python3.11-dev python3-pip python-is-python3 ffmpeg && \ rm -rf /var/lib/apt/lists/* +# Ensure Python 3.11 is used (for some reason, 3.10 is also installed...) +RUN update-alternatives --install /usr/bin/python python /usr/bin/python3.11 1 + # Create dirs for: # - Storing the source code: /src # - Storing the input & output files: /data @@ -14,16 +30,8 @@ RUN mkdir /src /data /model WORKDIR /src -ENV POETRY_NO_INTERACTION=1 \ - POETRY_VIRTUALENVS_IN_PROJECT=1 \ - POETRY_VIRTUALENVS_CREATE=1 \ - POETRY_CACHE_DIR=/tmp/poetry_cache - -RUN pip install poetry==1.8.2 - -COPY pyproject.toml poetry.lock ./ - -RUN poetry install --without dev --no-root && rm -rf $POETRY_CACHE_DIR +COPY --from=req ./requirements.txt requirements.txt +RUN python -m pip install --no-cache-dir -r requirements.txt # copy the rest into the source dir COPY ./ /src diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh index f064a26..686d9a0 100755 --- a/docker-entrypoint.sh +++ b/docker-entrypoint.sh @@ -2,6 +2,6 @@ echo "Starting Whisper ASR worker" -poetry run python main.py "$@" +python main.py "$@" echo "The worker has finished" \ No newline at end of file