diff --git a/Dockerfile b/Dockerfile index 08f9bdc..7183783 100644 --- a/Dockerfile +++ b/Dockerfile @@ -8,9 +8,9 @@ FROM python:3.10-slim as dependencies # Setup venv RUN python3 -m venv /venv ARG PATH="/venv/bin:$PATH" -RUN python3 -m pip install --upgrade pip setuptools +RUN --mount=type=cache,target=/root/.cache/pip pip install --upgrade pip setuptools # Install requirements -RUN python3 -m pip install torch torchaudio --extra-index-url https://download.pytorch.org/whl/cu118 +RUN --mount=type=cache,target=/root/.cache/pip pip install torch torchaudio --extra-index-url https://download.pytorch.org/whl/cu118 # Add git ARG DEBIAN_FRONTEND=noninteractive @@ -18,7 +18,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends git # Install whisperX COPY ./whisperX /code -RUN python3 -m pip install /code +RUN --mount=type=cache,target=/root/.cache/pip pip install /code FROM dependencies as load_model @@ -42,8 +42,12 @@ RUN python3 load_align_model.py ${LANG} FROM python:3.10-slim +# ffmpeg +COPY --link --from=mwader/static-ffmpeg:6.0 /ffmpeg /usr/local/bin/ +COPY --link --from=mwader/static-ffmpeg:6.0 /ffprobe /usr/local/bin/ + # Copy and use venv -COPY --from=dependencies /venv /venv +COPY --link --from=dependencies /venv /venv ARG PATH="/venv/bin:$PATH" ENV PATH=${PATH} @@ -51,7 +55,7 @@ ENV PATH=${PATH} RUN useradd -m -s /bin/bash appuser USER appuser -COPY --chown=appuser --from=load_model /cache /cache +COPY --link --chown=appuser --from=load_model /cache /cache WORKDIR /app ARG TORCH_HOME @@ -59,10 +63,6 @@ ARG HF_HOME ENV TORCH_HOME=${TORCH_HOME} ENV HF_HOME=${HF_HOME} -# ffmpeg -COPY --link --from=mwader/static-ffmpeg:6.0 /ffmpeg /usr/local/bin/ -COPY --link --from=mwader/static-ffmpeg:6.0 /ffprobe /usr/local/bin/ - ARG WHISPER_MODEL ENV WHISPER_MODEL=${WHISPER_MODEL} ARG LANG diff --git a/Dockerfile.no_model b/Dockerfile.no_model index 05bf612..9905d2a 100644 --- a/Dockerfile.no_model +++ b/Dockerfile.no_model @@ -21,8 +21,12 @@ RUN python3 -m pip install /code FROM python:3.10-slim +# ffmpeg +COPY --link --from=mwader/static-ffmpeg:6.0 /ffmpeg /usr/local/bin/ +COPY --link --from=mwader/static-ffmpeg:6.0 /ffprobe /usr/local/bin/ + # Copy and use venv -COPY --from=dependencies /venv /venv +COPY --link --from=dependencies /venv /venv ARG PATH="/venv/bin:$PATH" ENV PATH=${PATH} @@ -38,10 +42,6 @@ ARG HF_HOME ENV TORCH_HOME=${TORCH_HOME} ENV HF_HOME=${HF_HOME} -# ffmpeg -COPY --link --from=mwader/static-ffmpeg:6.0 /ffmpeg /usr/local/bin/ -COPY --link --from=mwader/static-ffmpeg:6.0 /ffprobe /usr/local/bin/ - ARG WHISPER_MODEL ENV WHISPER_MODEL=${WHISPER_MODEL} ARG LANG