Files
usaco/site/docker-compose.yml
adamfandClaude Opus 5.5 c972fa9fd9
Test and publish the site / test (push) Successful in 1m23s
Test and publish the site / publish (push) Failing after 4m22s
Run and lint solutions on the site
A new admin-only solve page, /p/<name>/solve, edits a problem's code in
C++ or Python (a dropdown switches between them), runs it on custom
input or against the saved tests with per-test verdicts (AC, WA, RE,
TLE, unchecked) and compile errors, marks lint diagnostics in the
editor, and saves the code back as a commit ("Edit <name>"). Drafts
stay in the browser per problem and language until saved. LeetCode
problems are C++ only, since their tests run through driver.h.

Code never runs in the site, which holds the Claude, Gitea and S3
secrets. A separate runner service (cmd/usacorunner, Dockerfile.runner)
does it in a container meant to have no environment, an internal-only
network, a read-only root apart from /tmp, and memory, CPU and pids
limits, with tini to reap orphans. Runs copy the CLI: the same g++
flags with -DLOCAL and the repo's headers, <io>.in on disk and on
stdin, <io>.out or stdout as the output, and usaco test's comparison.
Unlike the CLI they have CPU, memory, file and wall-clock limits.

C++ lint is g++'s warnings plus clang-tidy with a new .clang-tidy
(bugprone, performance and a few readability checks; template.cpp is
clean). Python lint is a syntax check plus ruff. template.py is the
Python starter, with a stdio() helper like template.rs's.

CI builds, smoke-tests and rolls out the runner image before the site.
The web_server stack needs a usaco-runner service before that rollout
can succeed.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-20 11:24:22 +01:00

66 lines
2.2 KiB
YAML

# Standalone development: the site serving THIS checkout's problems, with no
# login (AUTH_MODE=dev, everyone is the admin). http://localhost:8080/usaco/
#
# docker compose up --build
#
# The repo root is mounted read-only at /seed and cloned from there, and
# GIT_PUSH=false keeps edits made in the browser as commits in the
# container's own clone (docker compose exec usaco git -C /data/repo log),
# so nothing here can touch your working tree or the real remote. Only
# committed work shows up: it is a clone, not the working tree.
#
# The solve page's runs and lint go to the `runner` service (Dockerfile.runner),
# hardened as it is in production, apart from the network: here it shares the
# default one. It publishes no port; the site reaches it as runner:8081.
#
# This is NOT how it runs in production. There it is one service in the main
# site's docker-compose.yml, behind its nginx, cloning from Gitea and
# borrowing the site's login; see README.md.
services:
usaco:
build: .
ports:
- "8080:8080"
environment:
DEV_MODE: "true"
AUTH_MODE: dev
GIT_REMOTE_URL: file:///seed
GIT_PUSH: "false"
# The checkout belongs to your host user, which git refuses to read
# from as a different uid unless told it is safe.
GIT_CONFIG_COUNT: "1"
GIT_CONFIG_KEY_0: safe.directory
GIT_CONFIG_VALUE_0: "*"
# From your shell or a .env next to this file; blank turns the
# Explain button off.
CLAUDE_API_KEY: ${CLAUDE_API_KEY:-}
CLAUDE_MODEL: ${CLAUDE_MODEL:-}
# Recording reviews also need a transcriber. No S3 here, so
# recordings are not kept.
TRANSCRIBE_API_KEY: ${TRANSCRIBE_API_KEY:-${OPENAI_API_KEY:-}}
TRANSCRIBE_URL: ${TRANSCRIBE_URL:-}
TRANSCRIBE_MODEL: ${TRANSCRIBE_MODEL:-}
RUNNER_URL: http://runner:8081
volumes:
- ..:/seed:ro
- usaco-data:/data
depends_on:
- runner
runner:
build:
context: .
dockerfile: Dockerfile.runner
read_only: true
# Not noexec: the compiled program runs from here.
tmpfs:
- /tmp:size=256m,exec
mem_limit: 1g
cpus: 2
pids_limit: 128
cap_drop: [ALL]
security_opt: [no-new-privileges:true]
volumes:
usaco-data: