Jayesh1of1/caravan-layout-optimizer
0
1# ─────────────────────────────────────────────────────────────────────────────2# Caravan Layout Optimizer — OpenEnv Environment3# Optimised for HuggingFace Spaces (port 7860) and local Docker.4#5# Build: docker build -t caravan-optimizer .6# Run: docker run -p 7860:7860 \7# -e API_BASE_URL="https://api.openai.com/v1" \8# -e MODEL_NAME="gpt-4o-mini" \9# -e HF_TOKEN="your-key" \10# caravan-optimizer11# ─────────────────────────────────────────────────────────────────────────────12 13FROM python:3.11-slim14 15# ── Labels ────────────────────────────────────────────────────────────────────16LABEL maintainer="hackathon-submission"17LABEL description="Caravan Layout Optimizer — OpenEnv-compatible RL environment"18LABEL version="1.0.0"19 20# ── System dependencies ───────────────────────────────────────────────────────21# curl: used by Docker HEALTHCHECK22# No build tools needed — all deps are pure Python23RUN apt-get update \24 && apt-get install -y --no-install-recommends curl \25 && rm -rf /var/lib/apt/lists/*26 27# ── Working directory ─────────────────────────────────────────────────────────28WORKDIR /app29 30# ── Python dependencies ───────────────────────────────────────────────────────31# Copy requirements first so Docker layer cache is reused on code-only changes32COPY requirements.txt .33RUN pip install --no-cache-dir --upgrade pip \34 && pip install --no-cache-dir -r requirements.txt35 36# ── Application code ──────────────────────────────────────────────────────────37COPY . .38 39# ── Runtime environment variables ─────────────────────────────────────────────40# These are overridden at runtime via -e flags or HF Secrets.41# Defaults are placeholders only — do NOT commit real keys here.42ENV API_BASE_URL="https://api.openai.com/v1"43ENV MODEL_NAME="gpt-4o-mini"44ENV HF_TOKEN=""45ENV ENV_BASE_URL="http://localhost:7860"46 47# HuggingFace Spaces always uses port 786048ENV PORT=786049EXPOSE 786050 51# ── Health check ──────────────────────────────────────────────────────────────52# Automated hackathon validator pings GET / — must return 20053HEALTHCHECK \54 --interval=30s \55 --timeout=10s \56 --start-period=15s \57 --retries=3 \58 CMD curl -f http://localhost:7860/ || exit 159 60# ── Start server ──────────────────────────────────────────────────────────────61# Single worker (hackathon infra: 2 vCPU / 8 GB RAM constraint)62# --no-access-log reduces noise in HF Spaces logs63CMD ["uvicorn", "main:app", \64 "--host", "0.0.0.0", \65 "--port", "7860", \66 "--workers", "1", \67 "--no-access-log"]68 