Spaces:
Sleeping
Sleeping
Update Dockerfile
Browse files- Dockerfile +20 -26
Dockerfile
CHANGED
|
@@ -1,42 +1,36 @@
|
|
|
|
|
| 1 |
FROM python:3.10-slim
|
| 2 |
|
| 3 |
-
#
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
curl \
|
| 7 |
-
software-properties-common \
|
| 8 |
-
git \
|
| 9 |
-
libjpeg-dev \
|
| 10 |
-
zlib1g-dev \
|
| 11 |
-
&& rm -rf /var/lib/apt/lists/*
|
| 12 |
-
|
| 13 |
-
# Create a non-root user
|
| 14 |
-
RUN useradd -m streamlit_user
|
| 15 |
|
| 16 |
# Set working directory
|
| 17 |
WORKDIR /home/streamlit_user/app
|
| 18 |
|
| 19 |
-
#
|
| 20 |
-
RUN
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 21 |
|
| 22 |
-
#
|
| 23 |
-
|
| 24 |
|
| 25 |
-
#
|
| 26 |
-
|
|
|
|
| 27 |
|
| 28 |
-
# Copy
|
| 29 |
-
COPY requirements.txt ./requirements.txt
|
| 30 |
COPY src/ ./src/
|
| 31 |
|
| 32 |
-
#
|
| 33 |
-
RUN pip install --user --no-cache-dir -r requirements.txt
|
| 34 |
-
|
| 35 |
-
# Expose Streamlit's default port
|
| 36 |
EXPOSE 8501
|
| 37 |
|
| 38 |
-
#
|
| 39 |
-
|
| 40 |
|
| 41 |
# Run the Streamlit app
|
| 42 |
ENTRYPOINT ["streamlit", "run", "src/streamlit_app.py", "--server.port=8501", "--server.address=0.0.0.0"]
|
|
|
|
| 1 |
+
# Use the official lightweight Python image
|
| 2 |
FROM python:3.10-slim
|
| 3 |
|
| 4 |
+
# Set environment variables to avoid prompts during installs
|
| 5 |
+
ENV PYTHONDONTWRITEBYTECODE=1
|
| 6 |
+
ENV PYTHONUNBUFFERED=1
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
|
| 8 |
# Set working directory
|
| 9 |
WORKDIR /home/streamlit_user/app
|
| 10 |
|
| 11 |
+
# Install system dependencies
|
| 12 |
+
RUN apt-get update && apt-get install -y --no-install-recommends \
|
| 13 |
+
build-essential \
|
| 14 |
+
git \
|
| 15 |
+
curl \
|
| 16 |
+
libgl1-mesa-glx \
|
| 17 |
+
&& rm -rf /var/lib/apt/lists/*
|
| 18 |
|
| 19 |
+
# Copy requirements first to leverage Docker cache
|
| 20 |
+
COPY requirements.txt ./requirements.txt
|
| 21 |
|
| 22 |
+
# Install Python dependencies
|
| 23 |
+
RUN pip install --upgrade pip && \
|
| 24 |
+
pip install --no-cache-dir -r requirements.txt
|
| 25 |
|
| 26 |
+
# Copy the rest of your app files
|
|
|
|
| 27 |
COPY src/ ./src/
|
| 28 |
|
| 29 |
+
# Expose Streamlit default port
|
|
|
|
|
|
|
|
|
|
| 30 |
EXPOSE 8501
|
| 31 |
|
| 32 |
+
# Streamlit specific environment variable to disable browser opening
|
| 33 |
+
ENV STREAMLIT_SERVER_HEADLESS=true
|
| 34 |
|
| 35 |
# Run the Streamlit app
|
| 36 |
ENTRYPOINT ["streamlit", "run", "src/streamlit_app.py", "--server.port=8501", "--server.address=0.0.0.0"]
|