Spaces:
Sleeping
Sleeping
Commit ·
d2dcf2e
1
Parent(s): 3a2c9d3
edited dockerfile
Browse files- Dockerfile +14 -15
Dockerfile
CHANGED
|
@@ -1,23 +1,22 @@
|
|
| 1 |
# Use official Python image as base
|
| 2 |
FROM python:3.12-slim
|
| 3 |
|
| 4 |
-
#
|
| 5 |
-
|
|
|
|
|
|
|
| 6 |
|
| 7 |
-
|
| 8 |
-
COPY . /app
|
| 9 |
|
| 10 |
-
# Install
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
&& rm -rf /var/lib/apt/lists/*
|
| 14 |
|
| 15 |
-
#
|
| 16 |
-
|
| 17 |
-
&& pip install -r requirements.txt
|
| 18 |
|
| 19 |
-
# Expose
|
| 20 |
-
EXPOSE
|
| 21 |
|
| 22 |
-
#
|
| 23 |
-
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "
|
|
|
|
| 1 |
# Use official Python image as base
|
| 2 |
FROM python:3.12-slim
|
| 3 |
|
| 4 |
+
# Create a non-root user
|
| 5 |
+
RUN useradd -m -u 1000 user
|
| 6 |
+
USER user
|
| 7 |
+
ENV PATH="/home/user/.local/bin:$PATH"
|
| 8 |
|
| 9 |
+
WORKDIR /app
|
|
|
|
| 10 |
|
| 11 |
+
# Install dependencies as user
|
| 12 |
+
COPY --chown=user ./requirements.txt requirements.txt
|
| 13 |
+
RUN pip install --no-cache-dir --upgrade -r requirements.txt
|
|
|
|
| 14 |
|
| 15 |
+
# Copy all files as user
|
| 16 |
+
COPY --chown=user . /app
|
|
|
|
| 17 |
|
| 18 |
+
# Expose Hugging Face Spaces default port
|
| 19 |
+
EXPOSE 7860
|
| 20 |
|
| 21 |
+
# Start FastAPI app with Uvicorn on port 7860
|
| 22 |
+
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]
|