Spaces:
Running
Running
Create Dockerfile
Browse files- Dockerfile +35 -0
Dockerfile
ADDED
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Use the official Python image that matches the HF Spaces environment
|
2 |
+
FROM python:3.10-slim
|
3 |
+
|
4 |
+
# Set the working directory
|
5 |
+
WORKDIR /app
|
6 |
+
|
7 |
+
# [STEP 1] Install ONLY the necessary system dependencies.
|
8 |
+
# We need git and git-lfs to clone the model from the Hub.
|
9 |
+
# We avoid the problematic libgl1-mesa-glx package entirely.
|
10 |
+
RUN apt-get update && apt-get install -y --no-install-recommends \
|
11 |
+
git \
|
12 |
+
git-lfs \
|
13 |
+
&& git lfs install \
|
14 |
+
&& rm -rf /var/lib/apt/lists/*
|
15 |
+
|
16 |
+
# [STEP 2] Copy your requirements file and install Python packages.
|
17 |
+
COPY requirements.txt ./
|
18 |
+
RUN pip install --no-cache-dir -r requirements.txt
|
19 |
+
|
20 |
+
# [STEP 3] Copy the rest of your application code.
|
21 |
+
COPY . .
|
22 |
+
|
23 |
+
# [STEP 4] Set up a non-root user for security.
|
24 |
+
ENV HOME=/home/user \
|
25 |
+
PATH=/home/user/.local/bin:$PATH \
|
26 |
+
STREAMLIT_SERVER_HEADLESS=true \
|
27 |
+
STREAMLIT_SERVER_ENABLE_CORS=false \
|
28 |
+
STREAMLIT_SERVER_ENABLE_XSRF_PROTECTION=false \
|
29 |
+
STREAMLIT_BROWSER_GATHER_USAGE_STATS=false
|
30 |
+
RUN useradd -m -u 1000 user
|
31 |
+
USER user
|
32 |
+
|
33 |
+
# [STEP 5] Expose the Streamlit port and define the command to run the app.
|
34 |
+
EXPOSE 8501
|
35 |
+
CMD ["streamlit", "run", "app.py", "--server.port=8501", "--server.address=0.0.0.0"]
|