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]>
75 lines
2.9 KiB
Bash
75 lines
2.9 KiB
Bash
# Every variable the server reads. In production these are set by the main
|
|
# site's docker-compose.yml (see README.md); for standalone development,
|
|
# docker-compose.yml here sets what it needs.
|
|
|
|
# --- Core -------------------------------------------------------------------
|
|
# URL prefix everything is served under. The SPA is built for /usaco.
|
|
BASE_PATH=
|
|
# The clone lives in $DATA_DIR/repo (default /data).
|
|
DATA_DIR=
|
|
# Listen port (default 8080).
|
|
PORT=
|
|
# "true" enables gin debug logging, and is required for AUTH_MODE=dev.
|
|
DEV_MODE=
|
|
|
|
# --- Git --------------------------------------------------------------------
|
|
# What to clone. Production: http://gitea:3000/adamf/usaco.git (Gitea on the
|
|
# Docker network). Required.
|
|
GIT_REMOTE_URL=
|
|
# Default main.
|
|
GIT_BRANCH=
|
|
# HTTP credentials: a Gitea access token with read and write on the repo.
|
|
# Given to git through GIT_ASKPASS, never written into .git/config.
|
|
# GIT_USER defaults to adamf.
|
|
GIT_USER=
|
|
GIT_TOKEN=
|
|
# Who the site's commits are by. Defaults: "usaco site" / [email protected].
|
|
GIT_AUTHOR_NAME=
|
|
GIT_AUTHOR_EMAIL=
|
|
# "false" keeps edits as local commits (development). Default true.
|
|
GIT_PUSH=
|
|
# Fallback pull interval, a Go duration. Default 10m; the webhook is the
|
|
# normal trigger.
|
|
PULL_INTERVAL=
|
|
# Shared secret of the Gitea push webhook. Blank turns the hook off.
|
|
WEBHOOK_SECRET=
|
|
|
|
# --- Auth -------------------------------------------------------------------
|
|
# "forward" (default): ask the main site's backend. "dev": admit everyone.
|
|
AUTH_MODE=
|
|
# The site backend's validate-admin route, on the Docker network
|
|
# (default http://backend:8080/auth/validate-admin).
|
|
AUTH_VALIDATE_URL=
|
|
|
|
# --- Claude -----------------------------------------------------------------
|
|
# API key for the Explain button. Blank turns explanations off; the rest of
|
|
# the site is unaffected.
|
|
CLAUDE_API_KEY=
|
|
# Model for explanations (default claude-opus-5-5).
|
|
CLAUDE_MODEL=
|
|
|
|
# --- Recording reviews ------------------------------------------------------
|
|
# A review needs CLAUDE_API_KEY and a transcriber: anything that speaks
|
|
# OpenAI's /v1/audio/transcriptions. Blank key turns reviews off.
|
|
# OPENAI_API_KEY is read when TRANSCRIBE_API_KEY is blank.
|
|
TRANSCRIBE_API_KEY=
|
|
# Default https://api.openai.com; a self-hosted faster-whisper server's URL
|
|
# works too (with any non-blank key).
|
|
TRANSCRIBE_URL=
|
|
# Default whisper-1, which gives the word timestamps the pace and pause
|
|
# metrics come from.
|
|
TRANSCRIBE_MODEL=
|
|
# Optional: where recordings are kept for playback. All five or none; with
|
|
# none, a recording is thrown away once transcribed. Use a private bucket.
|
|
S3_ENDPOINT=
|
|
S3_REGION=
|
|
S3_BUCKET=
|
|
S3_ACCESS_KEY_ID=
|
|
S3_SECRET_ACCESS_KEY=
|
|
|
|
# --- Solve page -------------------------------------------------------------
|
|
# The runner service (cmd/usacorunner) that compiles, runs and lints code for
|
|
# the solve page, e.g. http://usaco-runner:8081. Blank turns Run and lint off;
|
|
# editing and saving code still work.
|
|
RUNNER_URL=
|