File size: 3,148 Bytes
70a9d5e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
034f196
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
# ML Debug Env β€” Dockerfile
# Build context root: ml_debug_env/  (same dir as openenv.yaml)
# Usage from ml_debug_env/:
#   docker build -f server/Dockerfile -t ml-debug-env:latest .
#   docker run -e GROQ_API_KEY=... -p 8000:8000 ml-debug-env:latest

FROM python:3.10-slim

# ── system packages ────────────────────────────────────────────────────────────
RUN apt-get update && \
    apt-get install -y --no-install-recommends \
        curl \
        git \
        build-essential && \
    rm -rf /var/lib/apt/lists/*

# ── working directory ──────────────────────────────────────────────────────────
WORKDIR /app

# ── Python deps: torch CPU wheel first (keeps layer small and cacheable) ───────
RUN pip install --no-cache-dir --upgrade pip && \
    pip install --no-cache-dir \
        torch \
        --index-url https://download.pytorch.org/whl/cpu

# ── Other Python deps (openenv-core, fastapi, openai, etc.) ───────────────────
COPY server/requirements.txt /app/requirements.txt
RUN pip install --no-cache-dir \
        git+https://github.com/meta-pytorch/OpenEnv.git && \
    pip install --no-cache-dir \
        fastapi>=0.115.0 \
        "uvicorn[standard]>=0.24.0" \
        python-multipart \
        aiofiles \
        "openai>=1.0.0" \
        "pydantic>=2.0"

# ── Application code ───────────────────────────────────────────────────────────
# Copy in order: models first (imported by both server and client)
COPY models.py      /app/models.py
COPY client.py      /app/client.py
COPY __init__.py    /app/__init__.py
COPY server/        /app/server/

# ── Environment ────────────────────────────────────────────────────────────────
# PYTHONPATH=/app so that `from models import ...` works from server/
ENV PYTHONPATH=/app
# Tell grader.py which Python exe to use for subprocess code execution
ENV PYTHON_EXEC=/usr/local/bin/python

EXPOSE 8000

# ── Health check ───────────────────────────────────────────────────────────────
HEALTHCHECK --interval=30s --timeout=10s --start-period=15s --retries=3 \
    CMD curl -f http://localhost:8000/health || exit 1

# ── Start server ───────────────────────────────────────────────────────────────
# Run from /app/server so relative imports within server/ still work
WORKDIR /app/server
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "8000", "--workers", "1"]