shivamsshhiivvaamm commited on
Commit
0fe4d83
·
verified ·
1 Parent(s): 0a87e25

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +19 -29
Dockerfile CHANGED
@@ -1,29 +1,19 @@
1
- # Use an official Python runtime as a parent image
2
- FROM python:3.11-slim
3
-
4
- # Set up a new user named "user" with user ID 1000 for security (common for HF Spaces)
5
- RUN useradd -m -u 1000 user
6
-
7
- # Set the working directory in the container
8
- WORKDIR /app
9
-
10
- # Copy the requirements file and install dependencies first (leverages cache)
11
- COPY --chown=user requirements.txt .
12
- RUN pip install --no-cache-dir -r requirements.txt
13
-
14
- # Copy the rest of the application code
15
- COPY --chown=user . .
16
-
17
- # Set environment variables
18
- ENV PYTHONPATH=/app
19
- ENV PORT=7860
20
- ENV PYTHONUNBUFFERED=1
21
-
22
- # Switch to the "user" user
23
- USER user
24
-
25
- # Hugging Face Spaces expects port 7860
26
- EXPOSE 7860
27
-
28
- # Run the application
29
- CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]
 
1
+ FROM python:3.11-slim
2
+
3
+ RUN useradd -m -u 1000 user
4
+
5
+ WORKDIR /app
6
+
7
+ COPY --chown=user requirements.txt .
8
+ RUN pip install --no-cache-dir -r requirements.txt
9
+
10
+ COPY --chown=user . .
11
+
12
+ ENV PYTHONPATH=/app
13
+ ENV PYTHONUNBUFFERED=1
14
+
15
+ USER user
16
+
17
+ EXPOSE 7860
18
+
19
+ CMD ["sh", "-c", "uvicorn main:app --host 0.0.0.0 --port $PORT"]