httpsAkayush commited on
Commit
c471abc
·
1 Parent(s): b5017bd
Files changed (1) hide show
  1. Dockerfile +32 -10
Dockerfile CHANGED
@@ -1,18 +1,40 @@
1
- FROM python:3.9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
 
3
- # # Set working directory
4
  WORKDIR /app
5
 
6
- # # Copy and install dependencies
7
- COPY requirements.txt .
8
  RUN pip install --no-cache-dir --upgrade -r requirements.txt
9
- RUN pip install --no-cache-dir fastapi uvicorn python-multipart
10
 
11
- # # Copy the rest of the app
12
- COPY . .
13
 
14
- # # Expose port (HF Spaces expects 7860)
15
- # EXPOSE 7860
16
 
17
- # # Start the FastAPI server
18
  CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
 
1
+ # FROM python:3.9
2
+
3
+ # # # Set working directory
4
+ # WORKDIR /app
5
+
6
+ # # # Copy and install dependencies
7
+ # COPY requirements.txt .
8
+ # RUN pip install --no-cache-dir --upgrade -r requirements.txt
9
+ # RUN pip install --no-cache-dir fastapi uvicorn python-multipart
10
+
11
+ # # # Copy the rest of the app
12
+ # COPY . .
13
+
14
+ # # # Expose port (HF Spaces expects 7860)
15
+ # # EXPOSE 7860
16
+
17
+ # # # Start the FastAPI server
18
+ # CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
19
+
20
+ FROM python:3.9-slim
21
+
22
+ # Create a non-root user
23
+ RUN useradd -m -u 1000 user
24
+ USER user
25
+ ENV PATH="/home/user/.local/bin:$PATH"
26
 
 
27
  WORKDIR /app
28
 
29
+ # Copy requirements and install
30
+ COPY --chown=user requirements.txt .
31
  RUN pip install --no-cache-dir --upgrade -r requirements.txt
 
32
 
33
+ # Copy app code and model
34
+ COPY --chown=user . .
35
 
36
+ # Expose the HF Spaces default port
37
+ EXPOSE 7860
38
 
39
+ # Start FastAPI server
40
  CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]