Spaces:
Sleeping
Sleeping
Update Dockerfile
Browse files- Dockerfile +16 -11
Dockerfile
CHANGED
|
@@ -2,28 +2,33 @@
|
|
| 2 |
FROM python:3.10-slim
|
| 3 |
|
| 4 |
# Set environment variables
|
| 5 |
-
ENV PYTHONDONTWRITEBYTECODE
|
| 6 |
-
ENV PYTHONUNBUFFERED
|
| 7 |
-
ENV PORT
|
| 8 |
|
| 9 |
# Set the working directory to the root where files are uploaded
|
| 10 |
WORKDIR /code
|
| 11 |
|
| 12 |
-
# Install system dependencies
|
| 13 |
RUN apt-get update && apt-get install -y --no-install-recommends \
|
| 14 |
build-essential \
|
| 15 |
&& rm -rf /var/lib/apt/lists/*
|
| 16 |
|
| 17 |
-
# Copy
|
| 18 |
-
# This
|
| 19 |
-
COPY . .
|
|
|
|
|
|
|
|
|
|
| 20 |
|
| 21 |
# Install dependencies from the copied requirements.txt
|
| 22 |
-
RUN pip install --no-cache-dir -
|
|
|
|
|
|
|
|
|
|
| 23 |
|
| 24 |
# Expose the HF Spaces default port
|
| 25 |
EXPOSE 7860
|
| 26 |
|
| 27 |
-
# Start the application
|
| 28 |
-
|
| 29 |
-
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
|
|
|
|
| 2 |
FROM python:3.10-slim
|
| 3 |
|
| 4 |
# Set environment variables
|
| 5 |
+
ENV PYTHONDONTWRITEBYTECODE=1
|
| 6 |
+
ENV PYTHONUNBUFFERED=1
|
| 7 |
+
ENV PORT=7860
|
| 8 |
|
| 9 |
# Set the working directory to the root where files are uploaded
|
| 10 |
WORKDIR /code
|
| 11 |
|
| 12 |
+
# Install system dependencies required for compiling certain Python packages
|
| 13 |
RUN apt-get update && apt-get install -y --no-install-recommends \
|
| 14 |
build-essential \
|
| 15 |
&& rm -rf /var/lib/apt/lists/*
|
| 16 |
|
| 17 |
+
# PRO-MOVE: Copy ONLY requirements.txt first to leverage Docker caching.
|
| 18 |
+
# This prevents PyTorch from re-downloading every time you change your Python code.
|
| 19 |
+
COPY requirements.txt .
|
| 20 |
+
|
| 21 |
+
# Upgrade pip FIRST to break the filelock backtracking loop
|
| 22 |
+
RUN pip install --no-cache-dir --upgrade pip
|
| 23 |
|
| 24 |
# Install dependencies from the copied requirements.txt
|
| 25 |
+
RUN pip install --no-cache-dir -r requirements.txt
|
| 26 |
+
|
| 27 |
+
# Now copy the rest of your application code
|
| 28 |
+
COPY . .
|
| 29 |
|
| 30 |
# Expose the HF Spaces default port
|
| 31 |
EXPOSE 7860
|
| 32 |
|
| 33 |
+
# Start the application using Uvicorn
|
| 34 |
+
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
|
|
|