rxmha125 commited on
Commit
63b2ff0
·
verified ·
1 Parent(s): 25b947a

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +7 -16
Dockerfile CHANGED
@@ -4,29 +4,20 @@ 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 where to cache models.
8
  ENV HF_HOME /code/.cache
9
 
10
- # --- *** ADD THIS LINE *** ---
11
- # Create the cache directory and change its ownership to the default 'python' user.
12
- # This gives our application the necessary permissions to write model files.
13
- RUN mkdir -p /code/.cache && chown -R python:python /code/.cache
14
- # --- ********************* ---
15
 
16
- # Copy the requirements file and install dependencies
17
  COPY ./requirements.txt /code/requirements.txt
18
  RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
19
 
20
- # Copy the rest of the application code
21
  COPY ./app.py /code/app.py
22
 
23
- # --- *** ADD THIS LINE TO SWITCH USER *** ---
24
- # Switch to the non-root 'python' user to run the application securely
25
- USER python
26
- # --- ************************************** ---
27
-
28
- # Expose the port the app runs on
29
  EXPOSE 8000
30
-
31
- # Command to run the application
32
  CMD ["uvicorn", "app: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
+ # This is a simpler and more direct fix for the permission error.
12
+ RUN mkdir -p /code/.cache && chmod -R 777 /code/.cache
 
 
13
 
14
+ # Copy and install requirements
15
  COPY ./requirements.txt /code/requirements.txt
16
  RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
17
 
18
+ # Copy application code
19
  COPY ./app.py /code/app.py
20
 
21
+ # Expose port and run application
 
 
 
 
 
22
  EXPOSE 8000
 
 
23
  CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "8000"]