Spaces:
Sleeping
Sleeping
Update Dockerfile
Browse files- Dockerfile +32 -29
Dockerfile
CHANGED
|
@@ -1,29 +1,32 @@
|
|
| 1 |
-
# Use an official Python runtime as a parent image
|
| 2 |
-
FROM python:3.
|
| 3 |
-
|
| 4 |
-
# Set the working directory in the container
|
| 5 |
-
WORKDIR /app
|
| 6 |
-
|
| 7 |
-
# Install system dependencies
|
| 8 |
-
RUN apt-get update && apt-get install -y \
|
| 9 |
-
build-essential \
|
| 10 |
-
&& rm -rf /var/lib/apt/lists/*
|
| 11 |
-
|
| 12 |
-
#
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
#
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
#
|
| 25 |
-
ENV GRADIO_SERVER_NAME="0.0.0.0"
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Use an official Python runtime as a parent image
|
| 2 |
+
FROM python:3.12-slim
|
| 3 |
+
|
| 4 |
+
# Set the working directory in the container
|
| 5 |
+
WORKDIR /app
|
| 6 |
+
|
| 7 |
+
# Install system dependencies
|
| 8 |
+
RUN apt-get update && apt-get install -y \
|
| 9 |
+
build-essential \
|
| 10 |
+
&& rm -rf /var/lib/apt/lists/*
|
| 11 |
+
|
| 12 |
+
# Create a non-root user for security and HF compatibility
|
| 13 |
+
RUN useradd -m -u 1000 user
|
| 14 |
+
USER user
|
| 15 |
+
ENV PATH="/home/user/.local/bin:${PATH}"
|
| 16 |
+
|
| 17 |
+
# Copy requirements first for better caching
|
| 18 |
+
COPY --chown=user requirements.txt .
|
| 19 |
+
RUN pip install --no-cache-dir --user -r requirements.txt
|
| 20 |
+
|
| 21 |
+
# Copy the rest of the application
|
| 22 |
+
COPY --chown=user . .
|
| 23 |
+
|
| 24 |
+
# Gradio Environment Variables
|
| 25 |
+
ENV GRADIO_SERVER_NAME="0.0.0.0" \
|
| 26 |
+
GRADIO_SERVER_PORT=7860 \
|
| 27 |
+
PYTHONUNBUFFERED=1
|
| 28 |
+
|
| 29 |
+
EXPOSE 7860
|
| 30 |
+
|
| 31 |
+
# Run the application
|
| 32 |
+
CMD ["python", "app.py"]
|