Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions modal-deploy/sunflower-grpo-inference-vllm/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
.venv
__pycache__
*.pyc
*.pyo
*.pyd
.pytest_cache
.mypy_cache
.ruff_cache
.coverage
.env
.env.*
.git
.gitignore
.DS_Store
cloudrun/
sunflower_grpo_combined_inference.ipynb
sunflower_grpo_vllm_modal.py
client.py
main.py
README.md
Dockerfile
.dockerignore

# Web: ship source, not build artifacts or deps.
web/node_modules
web/.next
web/out
web/.env
web/.env.*
1 change: 1 addition & 0 deletions modal-deploy/sunflower-grpo-inference-vllm/.python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.12
61 changes: 61 additions & 0 deletions modal-deploy/sunflower-grpo-inference-vllm/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# syntax=docker/dockerfile:1.6

# ---------- Stage 1: build the Next.js static frontend ----------
FROM node:22-slim AS web-builder

ENV NODE_ENV=production \
NEXT_TELEMETRY_DISABLED=1

WORKDIR /web

COPY web/package.json web/package-lock.json* ./
RUN npm install --no-audit --no-fund

COPY web/ ./
# Produces /web/out via `BUILD_MODE=export next build`.
RUN npm run build


# ---------- Stage 2: python deps via uv ----------
FROM python:3.12-slim AS py-builder

ENV UV_COMPILE_BYTECODE=1 \
UV_LINK_MODE=copy \
UV_PYTHON_DOWNLOADS=never \
PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1

COPY --from=ghcr.io/astral-sh/uv:0.5.11 /uv /uvx /usr/local/bin/

WORKDIR /app

COPY pyproject.toml uv.lock ./

RUN --mount=type=cache,target=/root/.cache/uv \
uv sync --frozen --no-install-project --no-dev

COPY fastapi_app.py ./


# ---------- Stage 3: runtime ----------
FROM python:3.12-slim AS runtime

ENV PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1 \
PATH="/app/.venv/bin:$PATH" \
PORT=8080

RUN groupadd --system --gid 1001 app \
&& useradd --system --uid 1001 --gid app --home-dir /app --shell /sbin/nologin app

WORKDIR /app

COPY --from=py-builder --chown=app:app /app/.venv /app/.venv
COPY --from=py-builder --chown=app:app /app/fastapi_app.py /app/fastapi_app.py
COPY --from=web-builder --chown=app:app /web/out /app/web/out

USER app

EXPOSE 8080

CMD ["sh", "-c", "uvicorn fastapi_app:app --host 0.0.0.0 --port ${PORT}"]
43 changes: 43 additions & 0 deletions modal-deploy/sunflower-grpo-inference-vllm/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Local dev helpers for the integrated frontend + backend app.
#
# Usage:
# make install # one-time: npm install + uv sync
# make web # build the Next.js static frontend (produces web/out/)
# make serve # build frontend, then run uvicorn with --reload on :8000
# make dev-web # hot-reload UI on :3000 (proxies API to :8000 via rewrites)
# make dev-api # backend only on :8000 with --reload (no static mount)
# make clean # remove generated frontend artifacts

PORT ?= 8000
HOST ?= 0.0.0.0

.DEFAULT_GOAL := help

.PHONY: help
help:
@awk 'BEGIN {FS = ":.*##"; printf "Targets:\n"} /^[a-zA-Z0-9_.-]+:.*##/ {printf " \033[36m%-10s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST)

.PHONY: install
install: ## One-time: npm install (in web/) + uv sync
cd web && npm install
uv sync

.PHONY: web
web: ## Build the Next.js static frontend → web/out/
cd web && npm run build

.PHONY: serve
serve: web ## Build frontend, then run uvicorn with --reload on $(PORT)
uv run uvicorn fastapi_app:app --host $(HOST) --port $(PORT) --reload

.PHONY: dev-api
dev-api: ## Backend only with --reload (no static mount)
uv run uvicorn fastapi_app:app --host $(HOST) --port $(PORT) --reload

.PHONY: dev-web
dev-web: ## Next.js dev server on :3000 (proxies API to http://localhost:$(PORT))
cd web && BACKEND_URL=http://localhost:$(PORT) npm run dev

.PHONY: clean
clean: ## Remove generated frontend artifacts
rm -rf web/.next web/out
Loading
Loading