rupeia_chatbot / Dockerfile
ayush2917's picture
Update Dockerfile
6af8173 verified
raw
history blame contribute delete
990 Bytes
# Use a lightweight Python base image
FROM python:3.9-slim
# Set the working directory
WORKDIR /app
# Copy requirements.txt first to cache dependencies
COPY requirements.txt .
# Install system dependencies and upgrade pip
RUN apt-get update && apt-get install -y --no-install-recommends \
&& rm -rf /var/lib/apt/lists/* \
&& pip install --upgrade pip \
&& pip install --no-cache-dir -r requirements.txt
# Copy the rest of the project files
COPY . .
# Create a non-root user for security
RUN useradd -m -u 1000 appuser
USER appuser
# Expose the port the app runs on
EXPOSE 5000
# Add a health check to prevent cold starts
HEALTHCHECK --interval=30s --timeout=5s --start-period=5s --retries=3 \
CMD curl -f http://localhost:5000/ || exit 1
# Configure gunicorn with explicit worker class and reduced workers
CMD ["gunicorn", "--workers=1", "--threads=2", "--worker-class=gthread", "--timeout=300", "--preload", "--log-level=debug", "--bind", "0.0.0.0:5000", "app:app"]