CoolFace
Apppublic

Alph4Centauri/email-summarization-api

sourceHugging Faceapache-2.0updated 1y agoView on Hugging Face
0likes
Dockerfile39 linesDownload Raw Back to root
1FROM python:3.10-slim
2
3# Set working directory
4WORKDIR /app
5
6# Set environment variables for production
7ENV PYTHONUNBUFFERED=1
8ENV PYTHONDONTWRITEBYTECODE=1
9ENV PORT=7860
10ENV DEBUG=False
11
12# Install system dependencies
13RUN apt-get update && apt-get install -y \
14    gcc \
15    g++ \
16    curl \
17    && rm -rf /var/lib/apt/lists/*
18
19# Upgrade pip and install Python dependencies
20COPY requirements.txt .
21RUN pip install --no-cache-dir --upgrade pip
22RUN pip install --no-cache-dir -r requirements.txt
23
24# Copy application code
25COPY app.py .
26
27# Create non-root user for security
28RUN useradd -m -u 1000 appuser && chown -R appuser:appuser /app
29USER appuser
30
31# Health check
32HEALTHCHECK --interval=30s --timeout=30s --start-period=5s --retries=3 \
33    CMD curl -f http://localhost:${PORT}/health || exit 1
34
35# Expose port
36EXPOSE $PORT
37
38# Start the application with gunicorn for production
39CMD ["gunicorn", "--bind", "0.0.0.0:7860", "--workers", "1", "--threads", "4", "--timeout", "300", "--worker-class", "gthread", "--max-requests", "100", "--max-requests-jitter", "10", "--preload", "app:app"]