Create Dockerfile
Browse files- Dockerfile +42 -0
Dockerfile
ADDED
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Use Python 3.10 slim image for smaller size
|
2 |
+
FROM python:3.10-slim
|
3 |
+
|
4 |
+
# Set working directory
|
5 |
+
WORKDIR /app
|
6 |
+
|
7 |
+
# Install system dependencies
|
8 |
+
RUN apt-get update && apt-get install -y \
|
9 |
+
gcc \
|
10 |
+
g++ \
|
11 |
+
make \
|
12 |
+
libffi-dev \
|
13 |
+
libssl-dev \
|
14 |
+
&& rm -rf /var/lib/apt/lists/*
|
15 |
+
|
16 |
+
# Copy requirements first for better caching
|
17 |
+
COPY requirements.txt .
|
18 |
+
|
19 |
+
# Install Python dependencies
|
20 |
+
RUN pip install --no-cache-dir -r requirements.txt
|
21 |
+
|
22 |
+
# Create directories for models and temp files
|
23 |
+
RUN mkdir -p /app/models /app/temp
|
24 |
+
|
25 |
+
# Copy application code
|
26 |
+
COPY app.py .
|
27 |
+
|
28 |
+
# Set environment variables
|
29 |
+
ENV PYTHONUNBUFFERED=1
|
30 |
+
ENV FLASK_APP=app.py
|
31 |
+
ENV FLASK_ENV=production
|
32 |
+
ENV PORT=7860
|
33 |
+
|
34 |
+
# Expose port
|
35 |
+
EXPOSE 7860
|
36 |
+
|
37 |
+
# Health check
|
38 |
+
HEALTHCHECK --interval=30s --timeout=30s --start-period=60s --retries=3 \
|
39 |
+
CMD curl -f http://localhost:7860/health || exit 1
|
40 |
+
|
41 |
+
# Command to run the application
|
42 |
+
CMD ["gunicorn", "--bind", "0.0.0.0:7860", "--workers", "1", "--timeout", "120", "--worker-class", "sync", "app:app"]
|