singhankur01 commited on
Commit
8c7c362
·
verified ·
1 Parent(s): e318724

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +10 -14
Dockerfile CHANGED
@@ -4,25 +4,21 @@ FROM python:3.11-slim
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 ["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
+ # --- ADD THIS LINE ---
8
+ # Set a writable cache directory for Hugging Face models to solve permission errors
9
+ ENV HF_HOME=/tmp/.cache/huggingface
10
 
11
+ # Copy the requirements file into the container
12
+ COPY ./requirements.txt /code/requirements.txt
 
 
13
 
14
+ # Install any needed packages specified in requirements.txt
15
+ RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
16
 
17
+ # Copy the rest of your app's code (app.py and the utils folder)
18
+ COPY . /code/
 
 
 
19
 
20
  # Expose the port the app runs on
21
  EXPOSE 7860
22
 
23
+ # Command to run the uvicorn server for FastAPI
24
  CMD ["python", "-m", "uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]