| FROM python:3.8.9 | |
| WORKDIR /app | |
| # Copy requirements first to leverage Docker cache | |
| COPY requirements.txt . | |
| # Install dependencies with specific version constraints | |
| RUN pip install --no-cache-dir -r requirements.txt | |
| # Create and switch to non-root user for security | |
| RUN useradd -m -u 1000 user | |
| USER user | |
| ENV HOME=/home/user | |
| ENV PATH=$HOME/.local/bin:$PATH | |
| # Set up application directory | |
| WORKDIR $HOME/app | |
| # Copy application files | |
| COPY --chown=user:user . . | |
| # Expose both Streamlit and FastAPI ports | |
| EXPOSE 7860 | |
| EXPOSE 8000 | |
| # Copy and make the start script executable | |
| COPY --chown=user:user start.sh . | |
| RUN chmod +x start.sh | |
| # Use the start script as the entrypoint | |
| CMD ["./start.sh"] | |