Spaces:
Sleeping
Sleeping
Update Dockerfile
Browse files- Dockerfile +11 -11
Dockerfile
CHANGED
|
@@ -1,25 +1,25 @@
|
|
| 1 |
# Start with an official Python base image.
|
| 2 |
-
# Using a "slim" version is a good practice for smaller container sizes.
|
| 3 |
FROM python:3.11-slim
|
| 4 |
|
| 5 |
# Set the working directory inside the container.
|
| 6 |
WORKDIR /app
|
| 7 |
|
| 8 |
-
#
|
| 9 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
|
| 11 |
-
#
|
| 12 |
-
|
| 13 |
RUN pip install --no-cache-dir -r requirements.txt
|
| 14 |
|
| 15 |
-
# Copy the rest of your application code
|
| 16 |
COPY . .
|
| 17 |
|
| 18 |
-
# Expose the port
|
| 19 |
-
# Hugging Face Spaces automatically provides a PORT variable, typically 7860.
|
| 20 |
-
# FastAPI will run on this port inside the container.
|
| 21 |
EXPOSE 7860
|
| 22 |
|
| 23 |
-
# The command to run your application
|
| 24 |
-
# We use Gunicorn as a robust production server.
|
| 25 |
CMD ["gunicorn", "-w", "1", "--preload", "-k", "uvicorn.workers.UvicornWorker", "-b", "0.0.0.0:7860", "main:app"]
|
|
|
|
| 1 |
# Start with an official Python base image.
|
|
|
|
| 2 |
FROM python:3.11-slim
|
| 3 |
|
| 4 |
# Set the working directory inside the container.
|
| 5 |
WORKDIR /app
|
| 6 |
|
| 7 |
+
# Create a directory for the model cache and set permissions
|
| 8 |
+
RUN mkdir -p /app/model_cache && chmod 777 /app/model_cache
|
| 9 |
+
|
| 10 |
+
# CRITICAL FIX: Set the Hugging Face cache directory to our writable folder
|
| 11 |
+
ENV HF_HOME /app/model_cache
|
| 12 |
+
ENV SENTENCE_TRANSFORMERS_HOME /app/model_cache
|
| 13 |
|
| 14 |
+
# Copy the requirements file and install dependencies.
|
| 15 |
+
COPY requirements.txt .
|
| 16 |
RUN pip install --no-cache-dir -r requirements.txt
|
| 17 |
|
| 18 |
+
# Copy the rest of your application code.
|
| 19 |
COPY . .
|
| 20 |
|
| 21 |
+
# Expose the port the application will run on.
|
|
|
|
|
|
|
| 22 |
EXPOSE 7860
|
| 23 |
|
| 24 |
+
# The command to run your application.
|
|
|
|
| 25 |
CMD ["gunicorn", "-w", "1", "--preload", "-k", "uvicorn.workers.UvicornWorker", "-b", "0.0.0.0:7860", "main:app"]
|