DevStack Guide
The CRAIG devstack is a Docker Compose environment that runs every piece of infrastructure and every application service on your own machine. It gives you a complete, self-contained development and testing environment: ephemeral data, pre-configured authentication, and realistic seed data.
Prerequisites
-
Docker Desktop (Windows/macOS) or Docker Engine (Linux)
-
Docker Compose v2 (included with Docker Desktop)
-
At least 8 GB of RAM allocated to Docker
|
On Windows, use Docker Desktop with the WSL 2 backend for best performance. |
Quick Start
cargo xtask dev start
The start command:
-
Builds all Docker images
-
Starts infrastructure (PostgreSQL, RabbitMQ, Keycloak, Garage)
-
Starts CRAIG services (rules, cases, placement, exchange, financial, reporting, security, intake, web)
-
Initializes the Garage S3-compatible object store (idempotent)
-
Waits for all services to pass health checks (up to 5 minutes)
-
Runs the
craig-seedone-shot container to load mock data
Once complete you will see:
==> CRAIG devstack is ready.
Open http://localhost:8080 to access the web UI. Log in with one of the test user accounts.
Command Reference
The cargo xtask dev command supports the following subcommands.
Running with no arguments or help prints usage information.
start
Build images, start all containers, initialize Garage, and wait for health checks.
cargo xtask dev start
This is the primary command for bringing up the devstack. If the images are already cached, subsequent starts are faster: only changed layers are rebuilt.
stop
Stop all containers and remove them — including the fault profile’s Toxiproxy sidecar
(#1636; before that fix the
profile-gated sidecar survived a stop).
Data volumes (Garage, PostgreSQL) are preserved, so a subsequent start will resume with existing data.
cargo xtask dev stop
reload
Rebuild containers and restart without wiping data. Useful after making code changes: the new binaries are compiled into fresh Docker images, but databases and object storage keep their data.
cargo xtask dev reload
This is equivalent to stop followed by start.
restart
Wipe all data and start fresh.
Removes all containers, volumes, and orphan resources, then performs a full start including Garage initialization and seed data loading.
cargo xtask dev restart
Use this when you want a completely clean environment (e.g., after schema changes or to reset seed data).
reseed
Wipe data volumes and restart the stack with cached images.
This is faster than restart because the built images are kept: only the containers are recreated and craig-seed re-run.
cargo xtask e2e runs it first, because the integration battery leaves data behind and the e2e suite needs a clean seed.
cargo xtask dev reseed
Typical duration: 30–60 seconds versus ~20 minutes for a full restart.
restart-service
Restart a single CRAIG application service without touching the rest of the stack.
Data volumes are preserved; the command polls the service’s /healthz endpoint and waits for a healthy response before returning.
Used by the E2E cookie-lifecycle suite to prove sessions survive a web-tier restart (ADR-013).
cargo xtask dev restart-service craig-web
cargo xtask dev restart-service craig-security-issuer --kill
--kill sends SIGKILL to every container of the service (no graceful shutdown), starts it again and waits for every
replica’s health (#2744; the identity capacity experiment’s killed-replica case, deployment guide § Identity capacity).
The service name is validated against the CRAIG application services list (craig-rules, craig-cases, craig-placement, craig-exchange, craig-financial, craig-reporting, craig-security, craig-security-issuer, craig-intake, craig-composition, craig-web, craig-portal, mock-server — CRAIG_SERVICES in xtask/src/docker.rs) to prevent arbitrary docker compose restart invocations.
clean
Stop everything and wipe all data without restarting.
Like restart but without the subsequent start — leaves the environment fully torn down.
cargo xtask dev clean --confirm
status
Display a formatted table showing the state, health, ports, and uptime of every service.
cargo xtask dev status
Example output:
CRAIG Devstack Status
=====================
Infrastructure:
SERVICE STATE HEALTH ADDRESS (project network) UPTIME
------- ----- ------ ------------------------- ------
postgres running healthy postgres:5432 47 minutes
postgres-test running healthy postgres-test:5432 47 minutes
rabbitmq running healthy rabbitmq:5672, rabbitmq:15672 47 minutes
keycloak running healthy keycloak:8080 47 minutes
garage running healthy garage:3900, garage:3903 47 minutes
Services:
SERVICE STATE HEALTH PORT(S) UPTIME
------- ----- ------ ------- ------
craig-rules running healthy 8001 47 minutes
craig-cases running healthy 8002 47 minutes
craig-placement running healthy 8003 47 minutes
craig-exchange running healthy 8004 47 minutes
craig-financial running healthy 8005 47 minutes
craig-reporting running healthy 8006 47 minutes
craig-security running healthy 8007 47 minutes
craig-intake running healthy 8008 47 minutes
craig-web running healthy 8080 10 minutes
mock-server running healthy 9090 47 minutes
One-shot:
SERVICE STATE HEALTH PORT(S) UPTIME
------- ----- ------ ------- ------
craig-seed exited - - Exited (0)
Volumes:
craig_garage-data
craig_garage-meta
If nothing is running, it prints CRAIG devstack is not running (no containers found).
logs
Follow container logs in real time. With no argument, follows all services. With a service name, follows only that service.
# All services
cargo xtask dev logs
# Single service
cargo xtask dev logs craig-rules
Press Ctrl+C to stop following.
If you pass an invalid service name, the script prints an error with the list of available services.
e2e
Run the Playwright end-to-end test suite against the running devstack. If the devstack is not running, it is started automatically.
# Run the full E2E suite (the Playwright report gives live counts;
# they drift too fast to pin here)
cargo xtask e2e
# Run only tests matching "rule" in the name
cargo xtask e2e --grep "rule"
# Run with a visible browser window
cargo xtask e2e --headed
# Step through tests interactively
cargo xtask e2e --debug
Any extra arguments are forwarded directly to npx playwright test inside the container.
On failure, a hint is printed with the path to the HTML report:
Hint: open tests/e2e/playwright-report/index.html for the full report
Services and Ports
Nothing publishes a host port (plan merge-trains-gate design 3, #2922). The tables give each service’s compose name and container port: on the project network — inside cargo xtask dev exec, and for every test process — a service is http://<service>:<port> (postgres:5432, http://keycloak:8080, …). The OIDC issuer is http://keycloak:8080/realms/craig.
For a browser on the host, cargo xtask dev start --profile dev layers docker-compose.dev.yml, which publishes five services on loopback and switches the issuer and the BFF redirect URIs to localhost:
| Service | Host URL (dev profile) |
Container |
|---|---|---|
keycloak |
http://localhost:8180 (issuer |
|
craig-web |
|
|
craig-portal |
|
|
craig-intake |
|
|
craig-intake-standalone-shines |
|
The the_compose_file_publishes_no_port_outside_the_dev_profile contract test (xtask) holds every other compose file to no ports: at all.
Infrastructure
| Service | Image | Container port(s) | Purpose |
|---|---|---|---|
PostgreSQL 18 |
|
5432 |
Database server; each CRAIG service gets its own database |
PostgreSQL 18 (test plane) |
|
5432 ( |
|
RabbitMQ 4.2 |
|
5672, 15672 |
Message broker (speaking AMQP, the standard message-queue protocol) plus its management UI |
Keycloak 26.5 |
|
8080 |
OpenID Connect (OIDC) identity provider; imports the |
Garage |
|
3900, 3903 |
S3-compatible object storage for file attachments |
CRAIG Services
| Service | Container port | Database | Purpose |
|---|---|---|---|
craig-rules |
8001 |
|
Rules and policy engine (rule sets in the JSON Decision Model, JDM) |
craig-cases |
8002 |
|
Case management (referrals, investigations, cases, plans) |
craig-placement |
8003 |
|
Placement and foster care (homes, placements, matching) |
craig-exchange |
8004 |
|
Data exchange and ICPC (partners, agreements, transactions) |
craig-financial |
8005 |
|
Financial management (payments, rate tables, claims) |
craig-reporting |
8006 |
|
Reporting and analytics (AFCARS, NCANDS, ad-hoc reports) |
craig-security |
8007 |
|
Security, audit logging, compliance reviews, NIST controls |
craig-security-issuer |
8011 |
|
The internal token issuer (ADR-085 D2, #2741): craig-security’s image as |
craig-intake |
8008 |
— (stateless edge per ADR-017; the pre-created |
Public intake: the anonymous child abuse/neglect reporting API |
craig-intake-keyring |
8010 |
|
Signer registry + replay ledger for the standalone-SHINES signed path only (ADR-042 §D8) |
craig-composition |
8009 |
|
Composition layer engine: arranges plugin surfaces (ADR-035) |
craig-web |
8080 |
— |
Web UI, built as a backend-for-frontend (BFF): it proxies to the backend services and handles authentication itself, so the browser never talks to them directly |
craig-portal |
8080 (host 8081 under the |
— |
The caregiver self-service portal, a second BFF beside craig-web (ADR-076) for the PORTAL roles — |
mock-server |
9090 |
— |
A stand-in for the typed partner systems of the stack’s configuration layers, so |
One-Shot Containers
| Container | Purpose |
|---|---|
craig-config-fetch |
Fetches each configuration layer |
Writes the devstack’s certificates for the partner-return listener
(a return, #3193) into the |
|
craig-seed |
Generates and loads seed data into all databases once the services are healthy, using the |
craig-e2e |
Playwright browser tests. Only runs on demand via |
Databases
PostgreSQL is pre-configured with nine CRAIG databases:
CREATE DATABASE craig_rules;
CREATE DATABASE craig_cases;
CREATE DATABASE craig_placement;
CREATE DATABASE craig_financial;
CREATE DATABASE craig_exchange;
CREATE DATABASE craig_reporting;
CREATE DATABASE craig_security;
CREATE DATABASE craig_intake;
CREATE DATABASE craig_composition;
craig_intake is pre-created but never populated, because the intake edge is stateless per
ADR-017. The databases are defined in
devstack/postgres/init.sql, which runs on first startup and also creates the
multibackend-profile IdP databases (authentik, zitadel) and the per-service
migration-owner/runtime role pairs
(#1310).
Schema application happens in the per-service craig-<svc>-migrate one-shot gates
(ADR-063); serving boot only verifies the schema.
Connection credentials: craig / craig (user/password), configured in docker-compose.yml.
Test Users (Keycloak)
The devstack imports a pre-configured craig realm with nine test users. The sub column is the UUID the realm
import pins for each user (the seed and the test fixtures reference these values, so they must not change).
| Username | Password | Roles | sub (pinned UUID) |
|---|---|---|---|
|
|
admin |
|
|
|
caseworker, supervisor |
|
|
|
caseworker, eligibility_worker |
|
|
|
readonly |
|
|
|
supervisor, county_director |
|
|
|
supervisor, regional_director |
|
|
|
admin, state_office |
|
|
|
county_director — a PURE office role with no operational role: the two-axis authorization probe user (#1624) |
|
|
|
foster_parent — a PORTAL role and no worker role: craig-web refuses the session (#1842); the portal admits it once a caregiver binding exists (ADR-076) |
|
The Keycloak admin console is available at http://localhost:8180 under the dev profile (cargo xtask dev start --profile dev; login: admin / admin).
Four clients are configured:
-
craig-api: a public client with direct access grants (the resource-owner password credentials flow, ROPC), used by the CLI and integration tests -
craig-ui: a public client using the authorization-code flow with PKCE (Proof Key for Code Exchange), used by the web UI -
craig-portal-ui: a public client using the authorization-code flow with PKCE for the self-service portals — CLIENT-level lifespans (access 300 s, session idle 1800 s, session max 28800 s) and audiences craig-placement + craig-financial ONLY (ADR-076, #1843) -
craig-portal: the portal BFF’s confidential client (realm roleservice:craig-portal, the same two audiences)
The realm carries 9 worker roles — admin, supervisor, caseworker, eligibility_worker, icpc_coordinator, readonly, county_director, regional_director, state_office — plus the 3 PORTAL roles (craig_auth::PORTAL_REALM_ROLES: foster_parent, family, provider), disjoint from the worker set. API handlers identify the acting worker by claims.sub; the web UI displays preferred_username (Security); the design is IdP-neutral with Keycloak as the reference backend (IdP integration).
Token lifetime for craig-api / craig-ui is 30 minutes.
Long-running test sessions may hit 401 errors if tokens expire.
|
Object Storage (Garage)
Garage provides S3-compatible object storage for file attachments (case documents, exchange files).
The start command initializes Garage automatically:
-
Assigns the single node to a data center zone
-
Applies the cluster layout
-
Imports a static API key (
GKdeadbeefdeadbeefdeadbeef) -
Creates the
craig-devbucket -
Grants read/write/owner permissions to the key
This initialization is idempotent: it skips if the bucket already exists.
Configuration
Environment Variables
Services are configured via CRAIG_<SERVICE>__* environment variables defined in docker-compose.yml.
Key variables:
| Variable | Purpose |
|---|---|
|
Keycloak’s pinned frontend URL (default |
|
Full issuer URL for JWT validation (default |
|
The browser-facing base of craig-web’s and craig-portal’s OIDC redirect URIs (default the container URLs |
|
Outbound-trigger consent per interface. The devstack sets |
|
Collection consent per interface, separate from the send consent above: whether an admin may collect what the partner published (#3188). Either consent variable must name an interface the deployment’s partner set has a leg of that kind for, or craig-exchange refuses to start (#3196). The devstack sets |
|
The partner-return listener (#3193): port |
|
Consent to refer a submitted Medicaid application to the eligibility system (IES), and, as its own consent, to take that system’s calls on the return listener (production default off for both). The seeded IES partner row links no agreement and names no caller, and no certificate is registered, so a referral’s admission holds |
|
Where a partner simulator’s calls to CRAIG go ( |
|
Public, obviously fake partner secrets for the auth tests (#1813): a partner row naming |
Passkeys (WebAuthn)
The keyring owns the passkey policy (ADR-082 D2); both SHINES intake instances fetch it at boot from GET /webauthn/config. On the devstack, the craig-intake-keyring service in docker-compose.yml sets CRAIG_INTAKE_KEYRINGWEBAUTHN_RP_ID to localhost and CRAIG_INTAKE_KEYRINGWEBAUTHN_ALLOWED_ORIGINS to two origins, one per instance: http://localhost:8011 (craig-intake-standalone-shines) and https://localhost:8013 (craig-intake-standalone-shines-tls), the fixed loopback ports a developer would publish them on. The dev profile publishes the first; the TLS instance is never published (#2922).
Why localhost: WebAuthn needs a secure context, and browsers treat http://localhost as one without TLS, so the plain-http instance qualifies as well as the TLS one. An RP ID is a host, not an origin, so the one RP ID covers both ports.
From a browser on the host, start the stack with --profile dev and open http://localhost:8011/keygen. A passkey created there is scoped to localhost. The TLS instance is not published: its certificate is self-signed, which a host browser does not trust. A browser that reaches intake by its container name is outside this policy: that host is neither the RP ID nor on the origin list. The Playwright project intake-ui-shines-tls therefore starts Chromium with a host-resolver rule that maps localhost:8013 to wherever the TLS instance listens, so its pages load from https://localhost:8013 and its virtual authenticator’s passkeys are accepted.
Split Keycloak URLs
Services use two Keycloak URLs:
-
OIDC_ISSUERis the URL that appears in JWTissclaims (Keycloak pins it throughKC_HOSTNAME):http://keycloak:8080/realms/craigby default,http://localhost:8180/realms/craigunder thedevprofile so a host browser can follow the login redirect. -
OIDC_INTERNAL_URLis the container URL (http://keycloak:8080/realms/craig) the services fetch discovery and JWKS from.
Without the dev profile the two are the same URL; tests read the issuer as TestConfig::oidc_issuer (CRAIG_TEST__OIDC_ISSUER, which cargo xtask dev exec sets under the profile).
Dockerfiles (Not Bind Mounts)
Configuration files (RabbitMQ definitions.json, Keycloak realm export, Postgres init script, Garage config) are baked into images via COPY in their respective Dockerfiles under devstack/.
This avoids a Docker Desktop on Windows bug where bind-mounted files are sometimes mounted as directories.
Config fetch (ADR-087, #2955)
No image carries jurisdiction configuration. The source lists are committed files under devstack/config-sources/,
generated from config-sources.lock by cargo xtask config env (#3143): fetch.env (every locked layer, for the
fetcher) and one <name>.env per jurisdiction layer (federal, then that layer). docker-compose.yml hands each to its
services through env_file: as CRAIG_CONFIG_SOURCE, so a plain docker compose reads the same lists cargo xtask
dev does (Deployment Guide § Running the compose stack without
xtask). A pin bump regenerates them in the same change: cargo xtask config env --check, a gate of cargo xtask
validate and a line of the car, fails naming each stale file, and the verbs that bring the stack up (dev start,
refresh, reload, restart, reseed) refuse stale files before any compose call, so the devstack never runs on
pins other than the lock’s. xtask passes compose only CRAIG_CONFIG_TRUST_HOST_DIR,
the checkout’s ci/config-trust/. The craig-config-fetch one-shot publishes the
layers into the craig-config volume. Every service that loads configuration mounts it read-only at /config with
CRAIG_CONFIG_ROOT=/config and CRAIG_CONFIG_SOURCE set to the georgia list: craig-rules, craig-cases (with its
migration gate and the craig-cases-rewrite tool service), craig-placement, craig-exchange, craig-financial,
craig-reporting, craig-security, craig-composition, craig-web, craig-intake, the three craig-intake-standalone*
services, craig-seed and the mock server, which serves the partner simulators those layers hold: Georgia’s ten
mocks come from its layer’s partners/simulators.wasm, and the seed’s mock partner rows from its manifest
(Partner modules). craig-intake-tx gets the texas list. Each takes its jurisdiction and its reference data
(the layer’s bundle/ directory: rates, codes, calendars, theme, terminology) from those layers, boots from the
verified commits, and the stateful services report them on GET /version with verified: true. craig-portal,
craig-intake-keyring, craig-security-issuer and the other migration gates load no configuration.
The devstack sets CRAIG_RULES__RULE_SET_AUTHORITY=api on craig-rules: the seed loads the rule sets of every
published layer (/config//current/.json) into craig-rules over the API, and the tests create and promote rule sets
the same way. Under the default, config, craig-rules reconciles its rule sets from the layers and its write routes
answer 409.
The stack records the names of the layers it is seeded from in .devstack/config-layers. A stack whose marker is
absent or names other layers is wiped and reseeded on the next dev start or dev refresh, once.
A refused fetch (a commit not signed by a key in ci/config-trust/, an unreachable repository) exits non-zero,
leaves /config/<name>/status.json saying why, and nothing that reads configuration starts:
cargo xtask dev logs craig-config-fetch shows the reason. Bumping a pin is a cached rebuild; the fetch and the seed
re-run against the new commits (Development Workflow).
Development Workflow
Making Code Changes
After modifying Rust source code, you must rebuild the Docker containers for changes to take effect:
cargo xtask dev reload
This rebuilds all images (Docker layer caching makes unchanged services fast) and restarts containers while preserving database data.
Running Integration Tests
Integration tests run on the host against the devstack services. Make sure to rebuild containers first if you’ve changed code:
# Rebuild and restart
cargo xtask dev reload
# Run the devstack battery (re-executes in craig-tools on the project network)
cargo xtask test --integration
Running E2E Tests
The Playwright e2e test suite runs in a Docker container against the web UI:
# Run the full suite (starts devstack if needed)
cargo xtask e2e
# Filter by test name
cargo xtask e2e --grep "dashboard"
# Debug a specific test interactively
cargo xtask e2e --debug --grep "login"
Connecting the CLI
The CRAIG CLI connects to devstack services via a profile configuration. The devstack publishes no host port, so run the CLI on the project network (cargo xtask dev exec — craig …, with the container URLs http://keycloak:8080/realms/craig, http://craig-rules:8001, …), or publish what you need. The profile below assumes ports reachable on localhost.
Create or update ~/.config/craig/profiles.toml (Linux/macOS) or %APPDATA%\craig\profiles.toml (Windows):
[devstack]
oidc_internal_url = "http://localhost:8180/realms/craig"
keycloak_client_id = "craig-api"
rules_url = "http://localhost:8001"
cases_url = "http://localhost:8002"
placement_url = "http://localhost:8003"
exchange_url = "http://localhost:8004"
financial_url = "http://localhost:8005"
reporting_url = "http://localhost:8006"
security_url = "http://localhost:8007"
intake_url = "http://localhost:8008"
Then use:
craig --profile devstack rules sets list
Troubleshooting
Service Fails to Start
Check the service logs for errors:
cargo xtask dev logs craig-rules
If a service fails its health check, the start command will time out after 5 minutes and print the last 20 log lines automatically.
Port Conflicts
The devstack publishes no host port, so it cannot collide with a host listener. Under the dev profile it binds 127.0.0.1:8180, 8080, 8081, 8008 and 8011; a listener already on one of those fails the start with the daemon’s address already in use message. Stop that listener, or start without --profile dev.
RabbitMQ Authentication Errors
The RabbitMQ user is defined in devstack/rabbitmq/definitions.json with a SHA-256 password hash — not via the RABBITMQ_DEFAULT_USER environment variable.
This is because the custom rabbitmq.conf (which loads definitions.json) overrides the Docker entrypoint’s generated config.
If you see AMQP authentication failures, verify that definitions.json contains a valid user entry.
Keycloak Token Expiry
Access tokens expire after 30 minutes. If integration tests or CLI commands start returning 401 errors after running for a while, re-authenticate:
craig --profile devstack auth login
Windows-Specific Issues
-
Git Bash path mangling: The xtask sets
MSYS_NO_PATHCONV=1to prevent Git Bash from converting/garagepaths to Windows paths. -
File bind-mount bug: Docker Desktop on Windows sometimes mounts files as directories. The devstack avoids this by baking config files into images via
COPYin Dockerfiles. Do not switch to bind mounts. -
Line endings: The
craig-seedcontainer runs a shell script that must have Unix line endings. The Dockerfile’scraig-seedstage runssed -i 's/\r$//'to strip Windows carriage returns.
File Layout
| Path | Purpose |
|---|---|
|
Service definitions, ports, environment variables, health checks |
|
Cargo xtask: the cross-platform home of |
|
PostgreSQL Dockerfile and |
|
RabbitMQ Dockerfile, |
|
Keycloak Dockerfile and |
|
Garage Dockerfile and |
|
|
|
Rust binary that generates deterministic, scalable seed SQL. Controlled via |
|
Multi-stage build for all CRAIG Rust services and tools |
|
Playwright test suite — Dockerfile, specs, page objects, fixtures |
CI/CD
The ci-integration job (.gitlab-ci.yml) brings the stack up with raw docker compose, naming the checkout’s project explicitly (docker compose -p "$(xtask dev project)"), then runs xtask test --integration (then spelled --fault-gate), e2e, security and perf, which re-execute in craig-tools on the project network through the runner’s Docker socket — the same path as a laptop. No issuer or hostname override is needed. Plan merge-trains-gate U3 (#1739) replaced the job with cargo xtask ci stages, and plan ci-dev-loop U4 (#3046) those with the car job, which runs cargo xtask dev start and the developer’s lanes (Quality Gates § CI: the car).