Repository navigation
Expand file tree
/
Copy pathDockerfile
More file actions
43 lines (33 loc) · 1.59 KB
/
Copy pathDockerfile
File metadata and controls
43 lines (33 loc) · 1.59 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
# MergeSE - container image
# Builds a CPU-only image. For GPU evaluations on the host, run with --gpus all
# and torch will pick CUDA automatically.
FROM python:3.11-slim
ENV PYTHONUNBUFFERED=1 \
PIP_NO_CACHE_DIR=1 \
PIP_DISABLE_PIP_VERSION_CHECK=1 \
HF_HOME=/data/hf \
TRANSFORMERS_CACHE=/data/hf
# System deps (curl/git for HF Hub downloads, build for safetensors wheels on uncommon archs)
RUN apt-get update && apt-get install -y --no-install-recommends \
git curl ca-certificates tini && \
rm -rf /var/lib/apt/lists/*
WORKDIR /app
COPY requirements.txt /app/requirements.txt
RUN pip install --upgrade pip && \
pip install --index-url https://download.pytorch.org/whl/cpu torch && \
pip install -r requirements.txt
COPY . /app
RUN mkdir -p /data/hf /app/artifacts /app/uploads
VOLUME ["/data/hf", "/app/artifacts", "/app/uploads"]
EXPOSE 8765
# Report container health via the app's /api/health endpoint so orchestrators
# can detect and restart a wedged server. start-period covers the first-boot
# import of torch/transformers.
HEALTHCHECK --interval=30s --timeout=5s --start-period=40s --retries=3 CMD curl -fsS http://localhost:8765/api/health || exit 1
# tini reaps zombie processes from cancelled jobs
ENTRYPOINT ["/usr/bin/tini", "--"]
# Must be -w 1 (single worker): the job registry is in-process memory, so a
# job started in worker A is a 404 from worker B. Scale with --threads instead
# of --workers until the job state moves to shared storage.
CMD ["gunicorn", "-w", "1", "-k", "gthread", "--threads", "16", "-t", "0", \
"-b", "0.0.0.0:8765", "server.app:app"]