Testshded commited on
Commit
47fae8e
·
verified ·
1 Parent(s): 5114987

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +11 -17
Dockerfile CHANGED
@@ -4,27 +4,21 @@ FROM python:3.11-slim
4
  # Set the working directory inside the container
5
  WORKDIR /code
6
 
7
- # Set an environment variable to tell Hugging Face libraries where to cache models.
8
- ENV HF_HOME /code/cache
9
 
10
- # --- THE FINAL FIX ---
11
- # Create the cache directory and make it writable by any user.
12
- # This solves the PermissionError in restrictive environments.
13
- RUN mkdir -p /code/cache && \
14
- chmod -R 777 /code/cache
15
- # ---------------------
16
 
17
- # Copy the requirements file into the container
18
  COPY ./requirements.txt /code/requirements.txt
19
-
20
- # Install the Python dependencies
21
  RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
22
 
23
- # Copy your application code into the container
24
- COPY ./main.py /code/main.py
25
 
26
- # Expose the port the app runs on (FastAPI default is 8000)
27
- EXPOSE 8000
28
 
29
- # The command to run when the container starts
30
- CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"]
 
4
  # Set the working directory inside the container
5
  WORKDIR /code
6
 
7
+ # Set environment variable for Hugging Face cache
8
+ ENV HF_HOME /code/.cache
9
 
10
+ # Create the cache directory and make it fully writable.
11
+ RUN mkdir -p /code/.cache && chmod -R 777 /code/.cache
 
 
 
 
12
 
13
+ # Copy and install requirements
14
  COPY ./requirements.txt /code/requirements.txt
 
 
15
  RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
16
 
17
+ # Copy application code (renamed to main.py to match your file)
18
+ COPY ./main.py /code/app.py
19
 
20
+ # Expose the port Hugging Face Spaces expects
21
+ EXPOSE 7860
22
 
23
+ # Run the application
24
+ CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]