Update Dockerfile
Browse files- Dockerfile +17 -13
Dockerfile
CHANGED
@@ -1,19 +1,23 @@
|
|
1 |
-
#
|
2 |
-
FROM python:3.9
|
3 |
|
4 |
-
#
|
5 |
-
|
|
|
|
|
|
|
6 |
|
7 |
-
#
|
8 |
-
|
9 |
-
COPY app.py .
|
10 |
|
11 |
-
#
|
12 |
-
|
13 |
|
14 |
-
#
|
15 |
-
|
16 |
|
17 |
-
#
|
18 |
-
|
19 |
|
|
|
|
|
|
1 |
+
# Use official Python runtime as base image
|
2 |
+
FROM python:3.9-slim
|
3 |
|
4 |
+
# Create a non-root user as required by Hugging Face Spaces
|
5 |
+
RUN useradd -m -u 1000 user
|
6 |
+
USER user
|
7 |
+
ENV HOME=/home/user \
|
8 |
+
PATH=/home/user/.local/bin:$PATH
|
9 |
|
10 |
+
# Set working directory
|
11 |
+
WORKDIR /home/user/app
|
|
|
12 |
|
13 |
+
# Copy requirements file first (for caching)
|
14 |
+
COPY --chown=user requirements.txt requirements.txt
|
15 |
|
16 |
+
# Install dependencies
|
17 |
+
RUN pip install --no-cache-dir --upgrade -r requirements.txt
|
18 |
|
19 |
+
# Copy the application code
|
20 |
+
COPY --chown=user . /home/user/app
|
21 |
|
22 |
+
# Run the FastAPI app on port 7860
|
23 |
+
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
|