File size: 2,219 Bytes
b92d20c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
# ──────────────────────────────────────────────────────────────────────────────
# Dockerfile β€” CodeReview-Env (HuggingFace Spaces compatible)
# Must be at the repository root for HF Spaces to pick it up.
# Build: docker build -t codereview-env .
# Run:   docker run -p 7860:7860 -e HF_TOKEN=hf_xxx codereview-env
# ──────────────────────────────────────────────────────────────────────────────
FROM python:3.11-slim

# System essentials
RUN apt-get update && apt-get install -y --no-install-recommends curl && \
    rm -rf /var/lib/apt/lists/*

WORKDIR /app

# ── Install Python dependencies first (maximise Docker layer caching) ────────
COPY server/requirements.txt requirements.txt
RUN pip install --upgrade pip --no-cache-dir && \
    pip install --no-cache-dir -r requirements.txt

# ── Copy project source ───────────────────────────────────────────────────────
COPY . .

# ── Install the codereview_env package (editable) ─────────────────────────────
RUN pip install --no-cache-dir -e .

# ── Environment defaults ───────────────────────────────────────────────────────
ENV PORT=7860
ENV HOST=0.0.0.0
ENV HF_DATASETS_CACHE=/app/.cache/datasets
ENV PYTHONUNBUFFERED=1

# ── Expose and start ──────────────────────────────────────────────────────────
EXPOSE 7860

HEALTHCHECK --interval=30s --timeout=10s --start-period=40s --retries=3 \
  CMD curl -f http://localhost:${PORT}/health || exit 1

CMD ["uvicorn", "server.app:app", "--host", "0.0.0.0", "--port", "7860"]