Run Open Code Review with Docker
run.sh runs Open Code Review on the current directory,
passing any arguments to ocr. airgapped.run.sh does the same
from a saved image on a host that cannot pull.
- Images
- GHCR
ghcr.io/hambn/open-code-review - Docker Hub
docker.io/hambn/open-code-review
- GHCR
- Use case
- Review the current checkout
On this page
Prerequisites
- Docker Engine 23 or later.
- An API key for an LLM provider
ocrsupports, such asANTHROPIC_API_KEYorOPENAI_API_KEY.
Review your changes
ocr needs a provider and model before it can review. It saves them in
/home/sysadmin/.opencodereview/config.json, which --rm deletes when the container
exits, so configure and review in the same container. Start a shell in the image with
your key and the checkout:
docker run -it --rm -e ANTHROPIC_API_KEY -v "$PWD:/workspace" \
--entrypoint zsh ghcr.io/hambn/open-code-review:ubuntu-browserThen, inside it:
ocr config set provider anthropic
ocr config set model <model>
ocr review # staged, unstaged, and untracked changes
ocr review --from main --to HEAD./run.sh <args> suits commands that need no saved settings, such as ./run.sh --help.
See the upstream configuration reference (opens in new tab)
for other providers and their variables.
Run without registry access
On a machine that can pull, save the image:
docker save ghcr.io/hambn/open-code-review:ubuntu-browser -o open-code-review.tarCopy the tar to the offline host and pass its path first; the remaining arguments go to
ocr:
./airgapped.run.sh open-code-review.tar --helpThe script loads the tar and runs OPEN_CODE_REVIEW_IMAGE with --pull=never. After
it has loaded the image once, start a shell as shown above with --pull=never added.
A review still needs network access to your LLM provider.
Variables
| Variable | Required | Purpose |
|---|---|---|
OPEN_CODE_REVIEW_IMAGE |
no | Image both scripts run. Defaults to ghcr.io/hambn/open-code-review:ubuntu-browser; set ghcr.io/hambn/open-code-review@sha256:<digest> to pin one build. |
Workspace
The current directory is mounted at /workspace, the image's working directory. ocr
runs as sysadmin (UID 1000); the checkout must be a Git repository for ocr review.
Files
run.shpulls the image if needed and runsocrwith your arguments.airgapped.run.shloads a saved tar and runs it without pulling.
File contents
airgapped.run.sh17 lines
#!/usr/bin/env bash
# Offline host: load the image from a tar saved on an online host, never pull.
# docker save ghcr.io/hambn/open-code-review:ubuntu-browser -o open-code-review.tar
set -euo pipefail
image=${OPEN_CODE_REVIEW_IMAGE:-ghcr.io/hambn/open-code-review:ubuntu-browser}
tar=${1:-open-code-review.tar}
shift $(($# > 0 ? 1 : 0))
[[ -f "$tar" ]] || {
echo "missing $tar; docker save it on an online host first" >&2
exit 1
}
docker load -i "$tar"
docker run -it --rm --pull=never \
-v "$PWD:/workspace" \
"$image" "$@"run.sh8 lines
#!/usr/bin/env bash
# Run Open Code Review against the current directory.
set -euo pipefail
image=${OPEN_CODE_REVIEW_IMAGE:-ghcr.io/hambn/open-code-review:ubuntu-browser}
docker run -it --rm \
-v "$PWD:/workspace" \
"$image" "$@"