Spaces:
Sleeping
Sleeping
Update Dockerfile
Browse files- Dockerfile +14 -11
Dockerfile
CHANGED
|
@@ -1,43 +1,46 @@
|
|
| 1 |
-
# Use NVIDIA CUDA 11.8 base
|
| 2 |
FROM nvidia/cuda:11.8.0-cudnn8-runtime-ubuntu22.04
|
| 3 |
|
| 4 |
-
# Setup
|
| 5 |
ENV DEBIAN_FRONTEND=noninteractive \
|
| 6 |
PYTHONUNBUFFERED=1 \
|
| 7 |
PIP_CACHE_DIR=/var/cache/pip
|
| 8 |
|
| 9 |
-
# 1. Install
|
| 10 |
RUN apt-get update && apt-get install -y --no-install-recommends \
|
| 11 |
python3.10 \
|
| 12 |
python3-pip \
|
| 13 |
python3-dev \
|
| 14 |
ffmpeg \
|
| 15 |
git \
|
|
|
|
| 16 |
pkg-config \
|
| 17 |
-
|
|
|
|
| 18 |
&& rm -rf /var/lib/apt/lists/*
|
| 19 |
|
| 20 |
# Set python3.10 as default
|
| 21 |
RUN ln -s /usr/bin/python3.10 /usr/bin/python
|
| 22 |
|
| 23 |
-
# 2. Setup User
|
| 24 |
WORKDIR /app
|
| 25 |
RUN useradd -m -u 1000 user
|
| 26 |
RUN chown -R user:user /app
|
| 27 |
USER user
|
| 28 |
ENV PATH="/home/user/.local/bin:$PATH"
|
| 29 |
|
| 30 |
-
# 3. Install Dependencies
|
| 31 |
COPY --chown=user requirements.txt requirements.txt
|
|
|
|
|
|
|
| 32 |
RUN pip install --no-cache-dir --upgrade pip && \
|
| 33 |
-
|
| 34 |
-
"torch==2.1.2" \
|
| 35 |
-
|
| 36 |
-
--index-url https://download.pytorch.org/whl/cu118 && \
|
| 37 |
pip install --no-cache-dir -r requirements.txt
|
| 38 |
|
| 39 |
# 4. Copy Code
|
| 40 |
COPY --chown=user . .
|
| 41 |
|
| 42 |
-
# 5. Launch
|
| 43 |
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]
|
|
|
|
| 1 |
+
# Use NVIDIA CUDA 11.8 base
|
| 2 |
FROM nvidia/cuda:11.8.0-cudnn8-runtime-ubuntu22.04
|
| 3 |
|
| 4 |
+
# Setup environment
|
| 5 |
ENV DEBIAN_FRONTEND=noninteractive \
|
| 6 |
PYTHONUNBUFFERED=1 \
|
| 7 |
PIP_CACHE_DIR=/var/cache/pip
|
| 8 |
|
| 9 |
+
# 1. Install System Dependencies
|
| 10 |
RUN apt-get update && apt-get install -y --no-install-recommends \
|
| 11 |
python3.10 \
|
| 12 |
python3-pip \
|
| 13 |
python3-dev \
|
| 14 |
ffmpeg \
|
| 15 |
git \
|
| 16 |
+
wget \
|
| 17 |
pkg-config \
|
| 18 |
+
# These libraries allow 'av' and other audio tools to compile
|
| 19 |
+
libavformat-dev libavcodec-dev libavdevice-dev libavutil-dev libswscale-dev libswresample-dev libavfilter-dev \
|
| 20 |
&& rm -rf /var/lib/apt/lists/*
|
| 21 |
|
| 22 |
# Set python3.10 as default
|
| 23 |
RUN ln -s /usr/bin/python3.10 /usr/bin/python
|
| 24 |
|
| 25 |
+
# 2. Setup User
|
| 26 |
WORKDIR /app
|
| 27 |
RUN useradd -m -u 1000 user
|
| 28 |
RUN chown -R user:user /app
|
| 29 |
USER user
|
| 30 |
ENV PATH="/home/user/.local/bin:$PATH"
|
| 31 |
|
| 32 |
+
# 3. Install Python Dependencies
|
| 33 |
COPY --chown=user requirements.txt requirements.txt
|
| 34 |
+
|
| 35 |
+
# WE SPLIT THE INSTALL to handle the index-url correctly
|
| 36 |
RUN pip install --no-cache-dir --upgrade pip && \
|
| 37 |
+
# Step A: Install Torch from PyTorch Index
|
| 38 |
+
pip install --no-cache-dir "torch==2.1.2" "torchaudio==2.1.2" --index-url https://download.pytorch.org/whl/cu118 && \
|
| 39 |
+
# Step B: Install the rest from standard PyPI
|
|
|
|
| 40 |
pip install --no-cache-dir -r requirements.txt
|
| 41 |
|
| 42 |
# 4. Copy Code
|
| 43 |
COPY --chown=user . .
|
| 44 |
|
| 45 |
+
# 5. Launch
|
| 46 |
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]
|