-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdockerfile
More file actions
41 lines (31 loc) · 1.21 KB
/
Copy pathdockerfile
File metadata and controls
41 lines (31 loc) · 1.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
FROM python:3.11-slim
# Set environment variables
ENV PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1 \
PIP_NO_CACHE_DIR=1 \
PIP_DISABLE_PIP_VERSION_CHECK=1 \
FLASK_APP=server.py
# Install system dependencies including curl for health checks
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
gcc \
python3-dev \
curl \
&& rm -rf /var/lib/apt/lists/*
# Set work directory
WORKDIR /app
# Copy requirements first for better caching
COPY requirements.txt .
# Install Python dependencies
RUN pip install --no-cache-dir -r requirements.txt
# Copy application code
COPY server.py .
# Create necessary directories (running as root, so no permission issues)
RUN mkdir -p downloads data
# Expose port (matching your Flask app's port 5000, but we'll map it to 8000 in Gunicorn)
EXPOSE 8000
# Health check using your existing /api/health endpoint
HEALTHCHECK --interval=30s --timeout=30s --start-period=5s --retries=3 \
CMD curl -f http://localhost:8000/api/health || exit 1
# Run with Gunicorn as root, using server:app since your file is server.py
CMD ["gunicorn", "--bind", "0.0.0.0:8000", "--workers", "4", "--timeout", "60", "--max-requests", "1000", "server:app"]