shakacode/react_on_rails/setup-docker-servers-for-ab-tests
Claude Code and agent skill by shakacode/react_on_rails
- community
Checking that the SKILL.md file is still in the repository.
Set up shaka-perf twin-servers — the Docker A/B testing infrastructure that runs your app twice (control vs experiment) so visreg/perf can compare two branches. Use this skill whenever the user wants to set up, configure, or debug twin-servers, "dockerize" their app for shaka-perf, write the twin-servers Dockerfile/Procfile/docker-compose, fill in the `twinServers` config, or get `shaka-perf servers` building and running — even if they just say "set up twin servers", "get the A/B servers running", or "make my app run under shaka-perf for perf testing".
Install
npx vskill@latest install shakacode/react_on_rails/setup-docker-servers-for-ab-testsSKILL.md
The same SKILL.md was published earlier as shakacode/react_on_rails/setup-docker-servers-for-ab-tests.
setup-docker-servers-for-ab-tests
[!NOTE]
Twin-servers runs two production-mode copies of one app side by side — control (the baseline branch) and experiment (your branch) — so shaka-perf compare can diff them for visual and performance regressions. This skill sets up the Docker infrastructure that makes that happen in the current project.
The whole point is an apples-to-apples comparison: control and experiment must be identical in every way _except the application code under test_ — same base image, dependencies, services, environment, data. Any incidental drift (a service only one side has, an env var that differs, a slower disk path) surfaces later as a phantom regression that's brutal to trace. Keep asking: _are these two sides truly identical?_
You produce, under a twin-servers/ directory in the project:
| File | Purpose | |
|---|---|---|
twin-servers/Dockerfile | Production-mode image (non-root user, embedded services, no CMD) | |
twin-servers/Dockerfile.dockerignore | Keeps the build context tight and stable | |
twin-servers/Procfile | Tells Overmind which server processes to run per side | |
twin-servers/docker-compose.yml | Only if needed — the bundled default works for most projects |
…plus a few small TWIN_SERVERS-gated guards in the app itself. The twinServers: slice in abtests.config.ts is already there — shaka-perf init writes it pre-filled, so you review and adjust it (Phase 1) rather than create it.
How the pieces run together
- `shaka-perf servers build` builds one Docker image per side. It auto-passes
UID,GID, andNON_ROOT_USERbuild args from the host user, plus anything indockerBuildArgs. If the control checkout is missing it offers togit cloneit for you. - `shaka-perf servers start-containers` brings the containers up with
command: sleep infinity(they idle — no server yet), then runs yoursetupCommandsin both containers in parallel. - `shaka-perf servers start-servers` runs Overmind against the
Procfile, which actually launches the app processes (puma, workers, SSR, …) inside the already-running containers. - `shaka-perf servers` with no subcommand ties it together: rebuild if needed → start containers → interactive menu.
Default to doing everything in the image. The Dockerfile should install dependencies, build the app, install backing services, and run migrations + seed the database at build time so a built image is fully self-contained. The container then just runs. setupCommands and a multi-service docker-compose are escape hatches for the rare bits that genuinely can't be baked in — reach for them only with good reason (Phase 2 and Phase 6 explain when). So: the Dockerfile builds and seeds the world; the Procfile starts the app; `setupCommands` cover only what can't be baked into the image.
Reference docs — load as needed
Detail too bulky for the main flow — read the relevant one when you hit that phase.
| File | Read it when… | |
|---|---|---|
references/writing-the-dockerfile.md | Writing or fixing twin-servers/Dockerfile — full annotated examples (minimal + a real multi-service app), the non-root-user recipe, embedding Postgres/Redis/Memcached, and every rule with its reasoning | |
references/compose-and-procfile.md | Writing the Procfile, or deciding whether you need a custom docker-compose.yml and how to pair services per side | |
references/troubleshooting.md | The build/verify loop fails, or before you call it done — failure→fix table and the A/B-diligence checklist |
Phase 0 — Survey the project (read-only)
Do not write anything yet. First understand what you're dockerizing, because the Dockerfile and config flow directly from it. Investigate:
- Stack & server command — Rails/puma? Node/Next? Django? How does the app normally boot in production, on what port? Check
Procfile,Procfile.dev,config/puma.rb,package.jsonscripts,bin/scripts. - Existing production Dockerfile — is there one to adapt? Adapting an existing, working production image is far safer than writing from scratch. Look in the repo root,
.docker/,config/, CI files. - Backing services — Postgres? MySQL? Redis? Memcached? Elasticsearch? Read
config/database.yml,docker-compose*.yml,Gemfile/package.json,.env.example, and the project's dev-setup docs (README,bin/setup). Every service the app needs at runtime must exist for both sides. - Background processes — Sidekiq/queues, an SSR/node renderer, asset watchers. Each becomes a Procfile line per side.
- Runtime versions —
.ruby-version,.node-version,package.json#engines. You will pass these as build args; never edit these project files to suit Docker (see the rule inreferences/writing-the-dockerfile.md). If the config usesos.availableParallelism()for CPU-aware parallelism, keep Node >= 18.14; this RSC FOUC artifact pins Node 22.12.0. - Existing setup scripts —
bin/setup,db:prepare,db:seed, migration tasks. Reuse these (run them in the Dockerfile build, so the prepared/seeded state is baked into the image) rather than reinventing them. Keep it DRY.
Gate — write a short Project Profile before moving on. A few lines: stack, server start command + port, list of services and how each will be provided (embedded in the image vs. a compose service), background processes, runtime versions, and which existing setup scripts you'll reuse. If you can't fill this in, you haven't surveyed enough — keep digging. This profile is the spec for everything that follows.
Phase 1 — Fill in the twinServers config
shaka-perf init already wrote a twinServers: block in abtests.config.ts, pre-filled with sensible defaults: controlDir derives from the current dir name + -control, and the CONTROL_PORT / EXPERIMENT_PORT constants are reused so the host-port mapping, the URLs visreg/perf hit, and the Procfile's readiness check can't drift. Review and adjust to the project — the block below is the shape to aim for:
Notes that save you debugging later:
- Image names and host volume dirs are auto-derived from a slug of the project path — you don't (and can't) set them. Two checkouts of the same repo therefore never collide.
- `composeFile` is optional. Omit it and the bundled default compose is used. Only add it in Phase 6 if you genuinely need extra services.
controlDir/experimentDir/dockerBuildDirare resolved relative to the project dir;~is expanded.
Phase 2 — Write the production Dockerfile
Create twin-servers/Dockerfile. Read `references/writing-the-dockerfile.md` first — it has annotated end-to-end examples and the full rationale. The essentials, with the why:
- Production-mode, but local. Run as close to real production as possible (same build, asset precompile, env), except prod-only externals (real payment APIs, prod DB) are stubbed and disabled via a
TWIN_SERVERS=trueenv var the app checks (Phase 4). Differences from prod are fine; differences _between the two sides_ are not. - Non-root user with host-matching UID/GID. Containers bind-mount a host directory, so the in-container user must match the host user or you get permission errors. Declare
ARG NON_ROOT_USER,ARG UID,ARG GID(re-declared after eachFROM) —servers buildfills them from the host automatically. - Put everything under that user's home (
/home/$NON_ROOT_USER/app,…/bundle,…/node), not/appor/usr/local/..., to avoid bind-mount permission conflicts. - `COPY --chown=$NON_ROOT_USER:$NON_ROOT_USER` for every copy so the user owns its files.
- Bake stable non-secret config into `ENV`, not docker-compose. Placeholder API keys,
TWIN_SERVERS=true, DB config, and cache endpoints belong in DockerfileENVso the image is self-contained and identical on both sides. Do not bake real secrets into imageENV; pass boot-only dummy values such asSECRET_KEY_BASEthrough the build command or the Procfile/runtime command when possible. Inline Procfile values avoid image-layer anddocker inspectexposure but remain visible in the container process list, so use them only for fixed dummies or replace them with a wrapper script/secret file. Reserve composeenvironment:strictly for the few values that _must_ differ between sides (e.g.PERF_EXPERIMENT). - Embed backing services in the image (install Postgres/Redis/Memcached in the Dockerfile) rather than as separate compose services. Simpler, fully isolated per side, no cross-container networking. See
references/writing-the-dockerfile.md. - Do all setup at build time — including migrations and seeding. Run
db:prepare/db:seedin aRUNso the data is baked into the image, identical on both sides. (A _running_ daemon is the one thing you can't bake in — hence the narrowsetupCommandsexception.) - Pass runtime versions as build args, e.g.
ENV NODE_VERSION=...driven bydockerBuildArgs. Don't modify.node-version/.ruby-version/engines. - Remove `CMD` and `ENTRYPOINT`. docker-compose uses
command: sleep infinityso the container idles and Overmind starts/stops the server independently. Leave anEXPOSE 3000(or your port) and a comment explaining the removal.
Phase 3 — Write the dockerignore
Create twin-servers/Dockerfile.dockerignore. Docker looks for <dockerfile-path>.dockerignore before the context-root .dockerignore, so naming it after the Dockerfile keeps twin-servers' ignore rules separate from any existing one. Paths are relative to the build context (dockerBuildDir), not to twin-servers/.
Two reasons it matters:
This is the start of the file. Read the full SKILL.md on GitHub.
Security
- Security scanPassed, 95 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckinginternal/analysis/rsc-fouc-shakaperf-artifacts/setup/generated-shakaperf-skills/setup-docker-servers-for-ab-tests/SKILL.md
Popularity
- Repository stars
- 5,192
- Repository forks
- 629
- 7-day trend score
- 43
Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/shakacode/react_on_rails/setup-docker-servers-for-ab-tests)