Spaces:
Running
Running
Update Dockerfile
Browse files- Dockerfile +19 -7
Dockerfile
CHANGED
@@ -1,16 +1,28 @@
|
|
1 |
-
|
2 |
-
# you will also find guides on how best to write your Dockerfile
|
3 |
|
4 |
-
|
|
|
|
|
|
|
5 |
|
|
|
6 |
RUN useradd -m -u 1000 user
|
7 |
USER user
|
8 |
-
ENV PATH="/home/user/.local/bin:$PATH"
|
9 |
|
|
|
|
|
10 |
WORKDIR /app
|
11 |
|
12 |
-
|
13 |
-
|
|
|
|
|
14 |
|
|
|
15 |
COPY --chown=user . /app
|
16 |
-
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
FROM python:3.9-slim
|
|
|
2 |
|
3 |
+
# System dependencies
|
4 |
+
RUN apt-get update && apt-get install -y --no-install-recommends \
|
5 |
+
build-essential gcc libffi-dev libpq-dev curl && \
|
6 |
+
apt-get clean && rm -rf /var/lib/apt/lists/*
|
7 |
|
8 |
+
# Create and switch to non-root user
|
9 |
RUN useradd -m -u 1000 user
|
10 |
USER user
|
|
|
11 |
|
12 |
+
# Set environment
|
13 |
+
ENV PATH="/home/user/.local/bin:$PATH"
|
14 |
WORKDIR /app
|
15 |
|
16 |
+
# Copy requirements and install
|
17 |
+
COPY --chown=user requirements.txt .
|
18 |
+
RUN pip install --no-cache-dir --upgrade pip && \
|
19 |
+
pip install --no-cache-dir -r requirements.txt
|
20 |
|
21 |
+
# Copy source code
|
22 |
COPY --chown=user . /app
|
23 |
+
|
24 |
+
# Expose port (optional for readability)
|
25 |
+
EXPOSE 7860
|
26 |
+
|
27 |
+
# Use Uvicorn with proper worker class if using FastAPI or async
|
28 |
+
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860", "--workers", "2"]
|