Spaces:
Running
Running
Restore full ML server (Space is working, just need real models)
Browse files- Dockerfile +16 -4
Dockerfile
CHANGED
|
@@ -6,19 +6,31 @@ WORKDIR /code
|
|
| 6 |
|
| 7 |
# Set environment variables
|
| 8 |
ENV PORT=7860
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
|
| 10 |
# Copy requirements first for better caching
|
| 11 |
COPY requirements.txt .
|
| 12 |
|
| 13 |
-
# Install
|
| 14 |
RUN pip install --no-cache-dir --upgrade pip && \
|
| 15 |
-
pip install --no-cache-dir
|
|
|
|
| 16 |
|
| 17 |
# Copy the rest of the application
|
| 18 |
COPY . .
|
| 19 |
|
|
|
|
|
|
|
|
|
|
| 20 |
# Make port 7860 available
|
| 21 |
EXPOSE 7860
|
| 22 |
|
| 23 |
-
# Run the FastAPI server
|
| 24 |
-
CMD ["uvicorn", "
|
|
|
|
| 6 |
|
| 7 |
# Set environment variables
|
| 8 |
ENV PORT=7860
|
| 9 |
+
ENV TRANSFORMERS_CACHE=/code/.cache/transformers
|
| 10 |
+
|
| 11 |
+
# Install system dependencies
|
| 12 |
+
RUN apt-get update && \
|
| 13 |
+
apt-get install -y --no-install-recommends \
|
| 14 |
+
build-essential \
|
| 15 |
+
git \
|
| 16 |
+
&& rm -rf /var/lib/apt/lists/*
|
| 17 |
|
| 18 |
# Copy requirements first for better caching
|
| 19 |
COPY requirements.txt .
|
| 20 |
|
| 21 |
+
# Install dependencies (add back torch and transformers)
|
| 22 |
RUN pip install --no-cache-dir --upgrade pip && \
|
| 23 |
+
pip install --no-cache-dir torch==2.1.0 transformers==4.46.3 && \
|
| 24 |
+
pip install --no-cache-dir -r requirements.txt
|
| 25 |
|
| 26 |
# Copy the rest of the application
|
| 27 |
COPY . .
|
| 28 |
|
| 29 |
+
# Create cache directory for transformers
|
| 30 |
+
RUN mkdir -p /code/.cache/transformers
|
| 31 |
+
|
| 32 |
# Make port 7860 available
|
| 33 |
EXPOSE 7860
|
| 34 |
|
| 35 |
+
# Run the main FastAPI server (not minimal)
|
| 36 |
+
CMD ["uvicorn", "server:app", "--host", "0.0.0.0", "--port", "7860"]
|