File size: 1,405 Bytes
916cd0d 878d137 916cd0d 4669654 916cd0d 4669654 9119671 4669654 9119671 4669654 916cd0d 4669654 b5167a4 a8d44c1 9119671 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# Use official python image
FROM python:3.10
# Install system dependencies (for H2O & Java)
RUN apt-get update && apt-get install -y openjdk-17-jre-headless
# Set environment variables
ENV PYTHONUNBUFFERED=1 \
PYTHONDONTWRITEBYTECODE=1 \
JAVA_HOME=/usr/lib/jvm/java-17-openjdk-amd64 \
PATH="$JAVA_HOME/bin:$PATH" \
STREAMLIT_SERVER_PORT=7860 \
STREAMLIT_SERVER_ADDRESS=0.0.0.0
# Create a non-root user
RUN useradd -m -s /bin/bash streamlit
# Create app directory and set permissions
RUN mkdir -p /app /app/saved_models /app/.streamlit \
&& chown -R streamlit:streamlit /app
# Set working directory
WORKDIR /app
# Copy requirements file
COPY requirements.txt .
# Install Python dependencies
RUN pip install --no-cache-dir -r requirements.txt
# Copy your application code
COPY . .
# Create Streamlit config file with XSRF protection disabled
RUN echo '[server]' > /app/.streamlit/config.toml \
&& echo 'maxUploadSize = 200' >> /app/.streamlit/config.toml \
&& echo 'enableXsrfProtection = false' >> /app/.streamlit/config.toml
# Set permissions
RUN chmod -R 755 /app \
&& chmod -R 777 /app/saved_models \
&& chown -R streamlit:streamlit /app
# Switch to non-root user
USER streamlit
# Expose the port Streamlit runs on
EXPOSE 7860
# Run Streamlit app with XSRF protection disabled
CMD ["streamlit", "run", "--server.enableXsrfProtection=false", "app.py"] |