gepeter commited on
Update Dockerfile
Browse files12345671 unmodified line9101112131415161718192021FROM python:3.9-slimWORKDIR /appRUN apt-get update && apt-get install -y \build-essential \curl \1 unmodified linegit \&& rm -rf /var/lib/apt/lists/*COPY requirements.txt ./COPY src/ ./src/RUN pip3 install -r requirements.txtEXPOSE 8501HEALTHCHECK CMD curl --fail http://localhost:8501/_stcore/healthENTRYPOINT ["streamlit", "run", "src/streamlit_app.py", "--server.port=8501", "--server.address=0.0.0.0"]1234567891011121 unmodified line141516171819202122232425262728293031323334353637383940414243444546# Use an official Python runtime as a parent imageFROM python:3.9-slim# Set the working directory in the containerWORKDIR /app# Install system dependencies (if any are needed beyond standard Python)# For a basic Streamlit app with 'requests', these might not all be strictly necessary,# but they are common for many Python projects and good to have.RUN apt-get update && apt-get install -y \build-essential \curl \1 unmodified linegit \&& rm -rf /var/lib/apt/lists/*# Copy the requirements file into the container at /appCOPY requirements.txt ./# Install any needed packages specified in requirements.txt# Use --no-cache-dir to reduce image sizeRUN pip install --no-cache-dir -r requirements.txt# Copy your application's main Python file into the container at /app# IMPORTANT: Replace 'streamlit_app.py' if your file is named differently (e.g., 'app.py')COPY streamlit_app.py ./# (Optional) If you are using Streamlit secrets and have a .streamlit folder:# COPY .streamlit/ ./.streamlit/# Make port 7860 available to the world outside this container# (Hugging Face Spaces typically uses 7860 for Streamlit, but 8501 is Streamlit's default.# It's best to match what HF expects if you don't override it in Space settings)# Let's stick to 7860 as per common HF practice for now. If you specifically set your Space# to use 8501, then change this and the CMD port.EXPOSE 7860# Define a health check for the container (optional but good practice for Spaces)# Streamlit has a health endpoint.HEALTHCHECK --interval=30s --timeout=30s --start-period=5s --retries=3 \CMD curl -f http://localhost:7860/_stcore/health || exit 1# Run streamlit_app.py when the container launches# The command uses 0.0.0.0 to bind to all network interfaces# The port should match the EXPOSEd port.ENTRYPOINT ["streamlit", "run", "streamlit_app.py", "--server.port=7860", "--server.headless=true", "--server.address=0.0.0.0"]
Dockerfile+30-5