ml-intern / Dockerfile
bep40's picture
Update Dockerfile with all auto-continue patches
836ae39 verified
Raw
History Blame
2.17 kB
# Restore from 4bac0e2 + patch frontend + backend models + auto-continue
FROM node:20-alpine AS frontend-builder
RUN apk add --no-cache git python3
RUN git clone --depth 1 https://huggingface.co/spaces/smolagents/ml-intern /source
# Patch frontend: add OpenRouter models
COPY patch_frontend.py /tmp/patch_frontend.py
RUN python3 /tmp/patch_frontend.py
# Patch auto-continue feature for free models
COPY patch_use_agent_chat_full.py /tmp/patch_use_agent_chat_full.py
RUN python3 /tmp/patch_use_agent_chat_full.py
COPY patch_chat_input.py /tmp/patch_chat_input.py
RUN python3 /tmp/patch_chat_input.py
COPY patch_sse_transport.py /tmp/patch_sse_transport.py
RUN python3 /tmp/patch_sse_transport.py
WORKDIR /source/frontend
RUN npm config set fetch-timeout 120000 && \
npm config set fetch-retries 3 && \
npm install && \
npm run build
# Stage 2: Production
FROM python:3.12-slim
COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/
RUN useradd -m -u 1000 user
WORKDIR /app
RUN apt-get update && apt-get install -y --no-install-recommends git curl ca-certificates && rm -rf /var/lib/apt/lists/*
RUN git clone --depth 1 https://huggingface.co/spaces/smolagents/ml-intern /tmp/source && \
cp /tmp/source/pyproject.toml /tmp/source/uv.lock ./ && \
cp -r /tmp/source/agent ./agent && \
cp -r /tmp/source/backend ./backend && \
cp -r /tmp/source/configs ./configs && \
rm -rf /tmp/source
RUN uv sync --no-dev --frozen
COPY --from=frontend-builder /source/frontend/dist ./static/
COPY configs/frontend_agent_config.json ./configs/frontend_agent_config.json
# Patch backend: accept new model IDs + auto-continue
COPY patch_models.py /tmp/patch_models.py
RUN python /tmp/patch_models.py
COPY patch_agent_loop.py /tmp/patch_agent_loop.py
RUN python /tmp/patch_agent_loop.py || echo "agent_loop patch not applied (may need adjustment)"
RUN mkdir -p /app/session_logs && chown -R user:user /app
USER user
ENV HOME=/home/user \
PYTHONUNBUFFERED=1 \
PYTHONPATH=/app \
PATH="/app/.venv/bin:$PATH"
EXPOSE 7860
WORKDIR /app/backend
# python:slim does not include bash by default; start.sh is POSIX-compatible.
CMD ["sh", "start.sh"]