-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDockerfile
More file actions
74 lines (61 loc) · 2.03 KB
/
Copy pathDockerfile
File metadata and controls
74 lines (61 loc) · 2.03 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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# ========================
# Base image: NVIDIA PyTorch
# ========================
FROM pytorch/pytorch:2.3.0-cuda12.1-cudnn8-runtime
ENV DEBIAN_FRONTEND=noninteractive
# ========================
# System dependencies (minimal)
# ========================
RUN apt-get update && apt-get install -y --no-install-recommends \
git curl wget ca-certificates \
&& rm -rf /var/lib/apt/lists/*
# ========================
# Working directory
# ========================
WORKDIR /app
# ========================
# Install Python dependencies first (better caching)
# ========================
COPY requirements.txt .
RUN pip install --upgrade pip && \
pip install --no-cache-dir -r requirements.txt
# ========================
# Hugging Face cache configuration
# ========================
ENV HF_HOME=/root/.cache/huggingface
ENV TRANSFORMERS_CACHE=/root/.cache/huggingface/transformers
ENV HF_HUB_DISABLE_SYMLINKS_WARNING=1
# ========================
# Copy project source
# ========================
COPY src/ src/
# ========================
# Create results directory for epxort
RUN mkdir -p /app/results
# ========================
# ---- ADD THIS LINE ----
RUN echo "--- START serve.py ---" && cat src/model/serve.py && echo "--- END serve.py ---"
# -----------------------
# ========================
# Environment variables
# ========================
ENV PYTHONPATH=/app/src
ENV CUDA_VISIBLE_DEVICES=0
ENV PORT=5000
# ========================
# Expose port
# ========================
EXPOSE 5000
# ========================
# Create non-root user
# ========================
RUN useradd -m appuser && chown -R appuser /app
USER appuser
# ========================
# Healthcheck endpoint
# ========================
HEALTHCHECK --interval=30s --timeout=3s --start-period=20s CMD curl -f http://localhost:5000/health || exit 1
# ========================
# Default command: Uvicorn production-ready
# ========================
CMD ["uvicorn", "model.serve:app", "--host", "0.0.0.0", "--port", "5000", "--workers", "2", "--timeout-keep-alive", "3600", "--log-level", "info"]