simran0608's picture
Update Dockerfile
776f231 verified
raw
history blame
1 kB
FROM python:3.9-slim
# Create non-root user
RUN useradd -m streamlituser
WORKDIR /app
# Install system dependencies
RUN apt-get update && apt-get install -y \
build-essential \
curl \
software-properties-common \
git \
libgl1 \
&& rm -rf /var/lib/apt/lists/*
# Set up config dirs and set permissions
RUN mkdir -p /app/.streamlit /app/.config /app/src && \
chown -R streamlituser:streamlituser /app
# Set environment variables
ENV HOME=/app
ENV XDG_CONFIG_HOME=/app/.config
# Switch to non-root user
USER streamlituser
# Copy files after switching to the user to preserve ownership
COPY --chown=streamlituser:streamlituser requirements.txt ./
COPY --chown=streamlituser:streamlituser src/ ./src/
# Install dependencies
RUN pip install --no-cache-dir -r requirements.txt
EXPOSE 8501
HEALTHCHECK CMD curl --fail http://localhost:8501/_stcore/health || exit 1
ENTRYPOINT ["streamlit", "run", "src/streamlit_app.py", "--server.port=8501", "--server.address=0.0.0.0"]