Sarthak005 commited on
Commit
7d8b696
·
verified ·
1 Parent(s): dbe1ff6

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +19 -11
Dockerfile CHANGED
@@ -1,18 +1,26 @@
1
- # Use the official Python 3.10.9 image
2
  FROM python:3.12.6
3
- USER user
4
- # Copy the current directory contents into the container at .
5
- COPY . .
6
 
7
- # Set the working directory to /
8
- WORKDIR /
 
 
 
 
 
 
9
 
10
- RUN chown -R user:user /
 
11
 
12
- # Install requirements.txt
13
- RUN pip install --no-cache-dir --upgrade -r /requirements.txt
14
 
15
- COPY --chown=user:user . /
 
 
 
 
16
 
17
- # Start the FastAPI app on port 7860, the default port expected by Spaces
18
  CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
 
1
+ # Use the official Python 3.12.6 image
2
  FROM python:3.12.6
 
 
 
3
 
4
+ # Create a new group and user
5
+ RUN groupadd -r user && useradd -r -g user user
6
+
7
+ # Set environment variable for cache directory
8
+ ENV TRANSFORMERS_CACHE=/app/hf_cache
9
+
10
+ # Create the cache directory and set permissions
11
+ RUN mkdir -p /app/hf_cache && chown -R user:user /app/hf_cache
12
 
13
+ # Set the working directory
14
+ WORKDIR /app
15
 
16
+ # Copy the current directory contents into the container at /app
17
+ COPY --chown=user:user . /app
18
 
19
+ # Install requirements
20
+ RUN pip install --no-cache-dir --upgrade -r requirements.txt
21
+
22
+ # Switch to the new user
23
+ USER user
24
 
25
+ # Start the FastAPI app on port 7860
26
  CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]