demo_env / Dockerfile
Jayal04's picture
Update Dockerfile
ca10486 verified
# Use a lightweight Python 3.9 base image
FROM python:3.9-slim
# Set the working directory inside the container
WORKDIR /app
# --- CRUCIAL ADDITION FOR PERMISSION ERRORS ---
# Set environment variables to direct cache/config files to a writable location (/tmp)
ENV HOME=/tmp \
MPLCONFIGDIR=/tmp \
HF_HOME=/tmp/huggingface_cache \
STREAMLIT_SERVER_PORT=8501 \
STREAMLIT_SERVER_ADDRESS=0.0.0.0
# Install system dependencies needed for some Python packages (e.g., git, build-essential)
RUN apt-get update && apt-get install -y \
build-essential \
curl \
software-properties-common \
git \
&& rm -rf /var/lib/apt/lists/*
# Copy the requirements file into the container's working directory
COPY requirements.txt ./
# Install Python dependencies from requirements.txt
RUN pip3 install --no-cache-dir -r requirements.txt
# Copy the application code from the root of your repository
COPY . .
# Expose the port Streamlit will run on
EXPOSE 8501
# Define a health check to ensure the application is running
HEALTHCHECK CMD curl --fail http://localhost:8501/_stcore/health
# Define the command to run your Streamlit application
ENTRYPOINT ["streamlit", "run", "streamlit_app.py", "--server.port=8501", "--server.address=0.0.0.0"]