singhankur01 commited on
Commit
4a5fd41
·
verified ·
1 Parent(s): 3e691b4

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +16 -9
Dockerfile CHANGED
@@ -4,18 +4,25 @@ FROM python:3.11-slim
4
  # Set the working directory in the container
5
  WORKDIR /code
6
 
7
- # Copy the requirements file into the container
8
- COPY ./requirements.txt /code/requirements.txt
9
 
10
- # Install any needed packages specified in requirements.txt
11
- RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
 
 
12
 
13
- # Copy the rest of your app's code (app.py and the utils folder)
14
- COPY . /code/
 
 
 
 
 
 
15
 
16
  # Expose the port the app runs on
17
  EXPOSE 7860
18
 
19
- # --- FINAL, ROBUST START COMMAND ---
20
- # This method is more explicit and can resolve path issues inside the container.
21
- CMD ["python", "-m", "uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
 
4
  # Set the working directory in the container
5
  WORKDIR /code
6
 
7
+ # Set the Hugging Face cache directory to a writable location
8
+ ENV HF_HOME=/code/.cache
9
 
10
+ # Create a non-root user and switch to it
11
+ RUN useradd --create-home --shell /bin/bash appuser
12
+ WORKDIR /home/appuser/app
13
+ USER appuser
14
 
15
+ # Copy only the requirements file first to leverage Docker cache
16
+ COPY --chown=appuser:appuser ./requirements.txt .
17
+
18
+ # Install dependencies
19
+ RUN pip install --no-cache-dir --upgrade -r requirements.txt
20
+
21
+ # Copy the rest of your app's code
22
+ COPY --chown=appuser:appuser . .
23
 
24
  # Expose the port the app runs on
25
  EXPOSE 7860
26
 
27
+ # Command to run the application
28
+ CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]