From f27bdd1219c8d9232a481fc8620b3153012e77ba Mon Sep 17 00:00:00 2001 From: Benedikt Wagener Date: Fri, 13 Dec 2024 19:17:14 +0100 Subject: [PATCH] test late copy of sources --- Dockerfile | 25 +++++-------------------- 1 file changed, 5 insertions(+), 20 deletions(-) diff --git a/Dockerfile b/Dockerfile index 9cf3bb2..d39388c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM nvidia/cuda:12.6.3-runtime-ubuntu22.04 AS base +FROM nvidia/cuda:12.6.3-runtime-ubuntu22.04 # note: the python3-pip package contains Python 3.10 on Ubuntu 22.04 RUN apt-get update \ @@ -6,7 +6,8 @@ RUN apt-get update \ && apt-get clean \ && rm -rf /var/lib/apt/lists/* -COPY . /app/UltraSinger +# copy only the requirements file to leverage container image build cache +COPY ./requirements.txt /app/UltraSinger/requirements.txt WORKDIR /app/UltraSinger # no need to run as root @@ -23,23 +24,7 @@ RUN pip install --no-cache-dir -r requirements.txt \ && pip install --no-cache-dir torch==2.3.0 torchvision==0.18.0 torchaudio==2.3.0 --index-url https://download.pytorch.org/whl/cu121 \ && pip install --no-cache-dir tensorflow[and-cuda]==2.16.1 -FROM nvidia/cuda:12.6.3-runtime-ubuntu22.04 AS runtime - -# note: the python3-pip package contains Python 3.10 on Ubuntu 22.04 -RUN apt-get update \ - && apt-get install git python3 ffmpeg -y \ - && apt-get clean \ - && rm -rf /var/lib/apt/lists/* - -RUN chown -R 1000:1000 /app/UltraSinger -USER 1000:1000 - -COPY --from=base /app/UltraSinger /app/UltraSinger - -# setup venv -ENV VIRTUAL_ENV=/app/UltraSinger/.venv -RUN python3 -m venv $VIRTUAL_ENV -ENV PATH="$VIRTUAL_ENV/bin:$PATH" - +# copy sources late to allow for caching of layers which contain all the dependencies +COPY . /app/UltraSinger WORKDIR /app/UltraSinger/src CMD ["bash" ]