rxmha125 commited on
Commit
135fbd1
·
verified ·
1 Parent(s): d95d4a2

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +23 -20
Dockerfile CHANGED
@@ -1,21 +1,24 @@
1
- # Use an official Python base image
2
- FROM python:3.11-slim
3
-
4
- # Set the working directory inside the container
5
- WORKDIR /code
6
-
7
- # Copy the requirements file and install dependencies
8
- # We use --index-url for the CPU version of torch to keep it smaller
9
- RUN echo "torch --index-url https://download.pytorch.org/whl/cpu" > /code/requirements.txt
10
- COPY ./requirements.txt /code/temp_requirements.txt
11
- RUN cat /code/temp_requirements.txt >> /code/requirements.txt && rm /code/temp_requirements.txt
12
- RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
13
-
14
- # Copy the rest of the application code
15
- COPY ./app.py /code/app.py
16
-
17
- # Expose the port the app runs on (FastAPI default is 8000)
18
- EXPOSE 8000
19
-
20
- # Command to run the application using uvicorn
 
 
 
21
  CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "8000"]
 
1
+ # Use an official Python base image
2
+ FROM python:3.11-slim
3
+
4
+ # Set the working directory inside the container
5
+ WORKDIR /code
6
+
7
+ # --- *** ADD THIS LINE *** ---
8
+ # Set an environment variable to tell Hugging Face where to cache models.
9
+ # This avoids permission errors by using a local, writable directory.
10
+ ENV HF_HOME /code/.cache
11
+ # --- ********************* ---
12
+
13
+ # Copy the requirements file and install dependencies
14
+ COPY ./requirements.txt /code/requirements.txt
15
+ RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
16
+
17
+ # Copy the rest of the application code
18
+ COPY ./app.py /code/app.py
19
+
20
+ # Expose the port the app runs on
21
+ EXPOSE 8000
22
+
23
+ # Command to run the application
24
  CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "8000"]