mcherif's picture
Fix cache init and copy full src
61e2d01
FROM python:3.11-slim
# Set environment variables
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1
ENV HOME=/tmp
#ENV STREAMLIT_CONFIG_DIR=/tmp/.streamlit
WORKDIR /app
# Install system dependencies
RUN apt-get update && apt-get install -y \
build-essential \
libglib2.0-0 \
libsm6 \
libxext6 \
libxrender-dev \
curl \
git \
&& rm -rf /var/lib/apt/lists/*
# Copy requirements and install
COPY requirements.txt ./
RUN pip install --no-cache-dir -r requirements.txt
# Install pipdeptree for debugging dependencies
RUN pip install pipdeptree
# Debugging: Save dependency tree and installed packages
RUN pipdeptree > /app/dependency-tree.txt
RUN pip list > /app/installed-packages.txt
# Debug: Output Python version and environment variables
RUN python --version > /app/python-version.txt
RUN env > /app/env.txt
# Ensure multipart is removed (if needed)
RUN pip uninstall -y multipart || true
# Copy model and app code
COPY models/vit-finetuned ./models/vit-finetuned
# Copy application source files
COPY ./src/ ./src/
# Copy assets
COPY ./images/plant-disease-logo.png ./images/plant-disease-logo.png
COPY ./README.md ./README.md
# Debug: List files in /app after copying everything
#RUN ls -lR /app > /app/files-list.txt
# Expose Streamlit port
EXPOSE 7860
# Healthcheck for Streamlit
#HEALTHCHECK CMD curl --fail http://localhost:7860/_stcore/health || exit 1
# Default to Streamlit; override CMD for FastAPI if needed
#CMD python -c "import sys, os; print('Python:', sys.version); print('Env:', dict(os.environ)); os.system('ls -lR /app');" && streamlit run src/streamlit_app.py --server.port=7860 --server.address=0.0.0.0
#CMD streamlit run src/streamlit_app.py --server.port=7860 --server.address=0.0.0.0
# To run FastAPI, comment out the above CMD and uncomment below:
#CMD python -c "import sys, os; print('Python:', sys.version); print('Env:', dict(os.environ)); os.system('ls -lR /app');" && uvicorn src.inference.app_fastapi:app --host 0.0.0.0 --port 7860
CMD python src/app_gradio.py