flower_recognition / Dockerfile
basaktamer's picture
Update Dockerfile
76b13ad verified
Raw History Blame Contribute Delete
1.19 kB
# 1. Start with Python 3.10 (Stable for TensorFlow 2.15)
FROM python:3.10-slim
# 2. Set the working directory
WORKDIR /app
# 3. Install Linux system libraries
# These are essential for OpenCV, TensorFlow, and health checks
RUN apt-get update && apt-get install -y \
build-essential \
libgl1 \
libglib2.0-0 \
curl \
&& rm -rf /var/lib/apt/lists/*
# 4. Upgrade pip and install requirements
# We copy requirements first to keep the build fast (caching)
COPY requirements.txt .
RUN pip install --no-cache-dir --upgrade pip && \
pip install --no-cache-dir -r requirements.txt
# 5. Copy the rest of your app (code and .h5 models)
COPY . .
# 6. Environmental Path Fix
# Ensures the system can always find the streamlit executable
ENV PYTHONPATH=/app
ENV PATH="/home/user/.local/bin:${PATH}"
# 7. Hugging Face Spaces strictly requires port 7860
EXPOSE 7860
# 8. Start Streamlit with all security and port flags
# Using 'python -m' is the most reliable way to launch in Docker
CMD ["python3", "-m", "streamlit", "run", "app.py", \
"--server.port=7860", \
"--server.address=0.0.0.0", \
"--server.enableCORS=false", \
"--server.enableXsrfProtection=false"]