File size: 2,190 Bytes
510ab6f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
bf60b3f
510ab6f
 
 
 
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
# ─────────────────────────────────────────────────────────────
#  FlexTime β€” Production Dockerfile
#  Compatible with HuggingFace Spaces (Docker SDK, port 7860)
#  Run: docker build -t flextime . && docker run -p 7860:7860 flextime
# ─────────────────────────────────────────────────────────────
FROM python:3.11-slim

# HF Spaces metadata labels
LABEL org.opencontainers.image.title="FlexTime"
LABEL org.opencontainers.image.description="Real-world AI workforce scheduling OpenEnv environment"
LABEL org.opencontainers.image.version="1.0.0"
LABEL space.tag="openenv"

# System deps (curl for healthcheck)
RUN apt-get update && apt-get install -y --no-install-recommends \
        curl \
    && rm -rf /var/lib/apt/lists/*

# HF Spaces requires a non-root user with uid=1000
RUN useradd -m -u 1000 -s /bin/bash flextime

WORKDIR /app

# ── Install Python dependencies (cached layer) ────────────────
COPY requirements.txt .
RUN pip install --no-cache-dir --upgrade pip \
 && pip install --no-cache-dir -r requirements.txt

# ── Copy application code ─────────────────────────────────────
COPY --chown=flextime:flextime . .

# Switch to non-root user
USER flextime

# HF Spaces always uses port 7860
EXPOSE 7860

# Health check β€” HF Spaces pings /health
HEALTHCHECK --interval=30s --timeout=10s --start-period=20s --retries=3 \
    CMD curl -f http://localhost:7860/health || exit 1

# ── Start server ──────────────────────────────────────────────
# Single worker for stateful in-memory environment
# PYTHONPATH ensures scripts.baseline can be imported by app/main.py
ENV PYTHONPATH=/app

CMD ["uvicorn", "server.app:app", \
     "--host", "0.0.0.0", \
     "--port", "7860", \
     "--workers", "1", \
     "--log-level", "info"]