From d161a9c067fac446e6e68c9db0144a370f69717f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B8=95=E6=96=AF=E5=8D=A1?= Date: Mon, 28 Oct 2024 22:21:55 +0100 Subject: [PATCH] Update Dockerfile --- Dockerfile | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/Dockerfile b/Dockerfile index c799f8df..2e8a552c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,19 +1,34 @@ # syntax=docker/dockerfile:1 - FROM python:3.10-bullseye +# Expose the required port EXPOSE 6969 +# Set up working directory WORKDIR /app -RUN apt update && apt install -y -qq ffmpeg aria2 && apt clean +# Install system dependencies, clean up cache to keep image size small +RUN apt update && \ + apt install -y -qq ffmpeg && \ + apt clean && rm -rf /var/lib/apt/lists/* +# Copy application files into the container COPY . . -RUN pip3 install --no-cache-dir -r requirements.txt +# Create a virtual environment in the app directory and install dependencies +RUN python3 -m venv /app/.venv && \ + . /app/.venv/bin/activate && \ + pip install --no-cache-dir --upgrade pip && \ + pip install --no-cache-dir python-ffmpeg && \ + pip install --no-cache-dir torch==2.3.1 torchvision==0.18.1 torchaudio==2.3.1 --index-url https://download.pytorch.org/whl/cu121 && \ + if [ -f "requirements.txt" ]; then pip install --no-cache-dir -r requirements.txt; fi -VOLUME [ "/app/logs/weights", "/app/opt" ] +# Define volumes for persistent storage +VOLUME ["/app/logs/"] -ENTRYPOINT [ "python3" ] +# Set environment variables if necessary +ENV PATH="/app/.venv/bin:$PATH" +# Run the app +ENTRYPOINT ["python3"] CMD ["app.py"]