FraudDetection / Dockerfile
useifabdelhady's picture
Update Dockerfile
763e8ff verified
Raw History Blame Contribute Delete
1.16 kB
# Base image
FROM python:3.10-slim
# Environment variables
ENV PYTHONUNBUFFERED=1 \
PYTHONDONTWRITEBYTECODE=1 \
PIP_NO_CACHE_DIR=1 \
MPLCONFIGDIR=/tmp/matplotlib \
HOME=/app \
PYTHONPATH=/app
# Set working directory
WORKDIR /app
# Create a non-root user and group
RUN addgroup --system appuser && adduser --system --group appuser
# Install system dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
libgomp1 \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
# Copy requirements first to leverage Docker cache
COPY requirements.txt .
# Install dependencies
RUN pip install --no-cache-dir --upgrade pip -r requirements.txt
# Copy the rest of the application code
COPY . .
# Change the ownership of the app directory
RUN chown -R appuser:appuser /app
# Switch to the non-root user
USER appuser
# Expose Streamlit default port
EXPOSE 7860
# FIX: Add --server.enableXsrfProtection=false to fix the 403 Forbidden error
CMD ["streamlit", "run", "src/deployment/app.py", "--server.port=7860", "--server.address=0.0.0.0", "--browser.gatherUsageStats=false", "--server.enableXsrfProtection=false"]