chatbot-langgraph / Dockerfile
Sameer-Handsome173's picture
Update Dockerfile
eb58c1b verified
# Use Python 3.11 slim image
FROM python:3.11-slim
# Set working directory
WORKDIR /app
# Install system dependencies (removed software-properties-common)
RUN apt-get update && apt-get install -y \
build-essential \
curl \
&& rm -rf /var/lib/apt/lists/*
# Copy requirements first (for better Docker caching)
COPY requirements.txt .
# Install Python dependencies
RUN pip install --no-cache-dir -r requirements.txt
# Copy all application files
COPY config.py .
COPY main.py .
COPY graph.py .
COPY tools.py .
COPY streamlit_app.py .
# Create directory for SQLite database
RUN mkdir -p /app/data
# Hugging Face Spaces uses port 7860 by default
# We'll run Streamlit on 7860 (public) and FastAPI on 8001 (internal)
EXPOSE 7860
# Create startup script
RUN echo '#!/bin/bash\n\
echo "🚀 Starting FastAPI Backend on port 8001..."\n\
python main.py &\n\
BACKEND_PID=$!\n\
echo "Backend PID: $BACKEND_PID"\n\
\n\
echo "⏳ Waiting 10 seconds for backend to initialize..."\n\
sleep 10\n\
\n\
echo "🎨 Starting Streamlit Frontend on port 7860..."\n\
python -m streamlit run streamlit_app.py \
--server.port=7860 \
--server.address=0.0.0.0 \
--server.headless=true \
--server.enableCORS=false \
--server.enableXsrfProtection=false\n\
' > /app/start.sh && chmod +x /app/start.sh
# Health check - check if Streamlit is responding
HEALTHCHECK --interval=30s --timeout=10s --start-period=60s --retries=3 \
CMD curl -f http://localhost:7860/_stcore/health || exit 1
# Run the startup script
CMD ["/app/start.sh"]