rohitkshirsagar19 commited on
Commit
28ab8e9
·
verified ·
1 Parent(s): 7910fa6

Update Dockerfile

Browse files
Files changed (1) hide show
  1. 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
- # Copy the requirements file into the container.
9
- COPY requirements.txt .
 
 
 
 
10
 
11
- # Install the Python dependencies.
12
- # The `--no-cache-dir` flag is a best practice for smaller Docker images.
13
  RUN pip install --no-cache-dir -r requirements.txt
14
 
15
- # Copy the rest of your application code into the container.
16
  COPY . .
17
 
18
- # Expose the port that the application will run on.
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 when the container starts.
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"]