KKIMS on-site docs
Local rehearsal

Local services with Docker Compose

Start the S3 stand-in and its two buckets, PostgreSQL 18 and Keycloak with the kims realm and test users, and check each one answers.

Three containers stand in for what KIMS already runs: an S3 gateway for the two buckets, PostgreSQL 18 for RDS, and Keycloak 26.4 for KIMS's own Keycloak. Jenkins is a fourth, started separately on Jenkins.

All of them are defined in local/docker-compose.yml (Compose project kims-v2), so every docker compose command on this page runs from the repo (<KIMS_FOLDER>/repos/kims-v2) and names that file with -f.

#Before you start

  • Docker is running: docker info --format "{{.ServerVersion}}" prints a version. See Docker.
  • .env.local exists: The env file.
  • npm install has been run in the repo (the bucket script uses the repo's AWS SDK): Get the code.

#Quick way: all three at once

Run from <KIMS_FOLDER>:

bash
node deployment-steps/scripts/deploy.mjs local up
bash
node deployment-steps/scripts/deploy.mjs local up
powershell
node deployment-steps/scripts/deploy.mjs local up

It runs, in order, local storage up, local db up, local keycloak up, then local db seed if the database has no content yet. Each part prints [n/m] progress lines, and it ends:

text
OK: the local services are up and the database is seeded.
Next: node deployment-steps/scripts/deploy.mjs local apps prepare

The first time it downloads three images and loads the data bundle (a few minutes). From stopped services with their data kept, it took 42 seconds on the engineer's Windows laptop (2026-11-28). It stops at the first part that fails and names it. Safe to run again.

Note

local up seeds the database from the bundle, which is covered on Database and content. The rest of this page does the services one at a time.

#Object storage (the S3 stand-in)

The stand-in is SeaweedFS's S3 gateway. It holds two buckets: kims-assets (the media library: uploads and their resized copies) and kims-website (the built website).

#Quick way

Run from <KIMS_FOLDER>:

bash
node deployment-steps/scripts/deploy.mjs local storage up
bash
node deployment-steps/scripts/deploy.mjs local storage up
powershell
node deployment-steps/scripts/deploy.mjs local storage up

You should see, at the end:

text
    kims-assets: N objects
    kims-website: N objects

OK: S3 stand-in on http://127.0.0.1:9100, buckets kims-assets, kims-website.

#1. Start the S3 service

Run from the repo:

bash
docker compose -f local/docker-compose.yml up -d --wait s3
bash
docker compose -f local/docker-compose.yml up -d --wait s3
powershell
docker compose -f local/docker-compose.yml up -d --wait s3

You should see Container kims-v2-s3-1 Healthy at the end. The first time, Docker pulls chrislusf/seaweedfs:4.54 first.

It listens on http://127.0.0.1:9100. Its data is in the Docker volume kims-v2_s3-data, so it survives restarts.

Note

The service runs with a fixed -volume.max=100. With 0, SeaweedFS sizes itself from the Docker VM's free disk, which on a full laptop gave a dozen slots; each bucket takes seven, so the second bucket could never be written. If you see writes failing on a new machine, check you haven't changed that line.

#2. Create the buckets

Run from the repo:

bash
node --env-file=.env.local scripts/local-buckets.mjs
bash
node --env-file=.env.local scripts/local-buckets.mjs
powershell
node --env-file=.env.local scripts/local-buckets.mjs

The first time you should see [dev:up] made bucket kims-assets and [dev:up] made bucket kims-website. When they exist, it prints nothing. The names and keys come from .env.local.

#3. Check it answers

bash
curl -s -o /dev/null -w "%{http_code}\n" http://127.0.0.1:9100/healthz
bash
curl -s -o /dev/null -w "%{http_code}\n" http://127.0.0.1:9100/healthz
powershell
curl.exe -s -o NUL -w "%{http_code}" http://127.0.0.1:9100/healthz

You should see 200. The buckets stay empty until Database and content loads the media and Site build fills the website bucket.

#PostgreSQL 18

#Quick way

Run from <KIMS_FOLDER>:

bash
node deployment-steps/scripts/deploy.mjs local db up
bash
node deployment-steps/scripts/deploy.mjs local db up
powershell
node deployment-steps/scripts/deploy.mjs local db up

It starts Postgres, creates the database if it's missing, runs the migrations, and ends OK: database kims on 127.0.0.1:5418 is up to date. The migrations are explained on Database and content.

#1. Start Postgres

Run from the repo:

bash
docker compose -f local/docker-compose.yml up -d --wait postgres
bash
docker compose -f local/docker-compose.yml up -d --wait postgres
powershell
docker compose -f local/docker-compose.yml up -d --wait postgres

You should see Container kims-v2-postgres-1 Healthy.

What you get:

  • PostgreSQL 18 on 127.0.0.1:5418, so it doesn't clash with a Postgres you may already run on 5432.
  • The database kims, owned by user kims. The password is in local/docker-compose.yml (POSTGRES_PASSWORD) and in DATABASE_URL in .env.local.
  • A second database, keycloak, made by local/postgres/init.sql the first time the volume is empty. Keycloak keeps its data there.
  • The data in the Docker volume kims-v2_postgres-data, mounted at /var/lib/postgresql (the PostgreSQL 18 image's layout).

#2. Check it answers

The container has psql, so you need no client on your machine. Run from the repo:

bash
docker compose -f local/docker-compose.yml exec -T postgres psql -U kims -d kims -tAc "select version()"
bash
docker compose -f local/docker-compose.yml exec -T postgres psql -U kims -d kims -tAc "select version()"
powershell
docker compose -f local/docker-compose.yml exec -T postgres psql -U kims -d kims -tAc "select version()"

You should see a line starting PostgreSQL 18..

Tip

To use your own psql 18 client instead, connect to 127.0.0.1 port 5418, user kims, database kims. See Database tools.

#Keycloak with the kims realm

Keycloak 26.4 runs in development mode (start-dev) and imports local/keycloak/kims-realm.json on its first start. It stands in for KIMS's Keycloak; the CMS signs people in through it.

#Quick way

Run from <KIMS_FOLDER>:

bash
node deployment-steps/scripts/deploy.mjs local keycloak up
bash
node deployment-steps/scripts/deploy.mjs local keycloak up
powershell
node deployment-steps/scripts/deploy.mjs local keycloak up

It starts Keycloak (and Postgres, if it isn't running), waits until healthy, fetches the realm's discovery document, checks its issuer equals KEYCLOAK_ISSUER in .env.local, and ends OK: Keycloak is up with the kims realm.

#1. Start Keycloak

Run from the repo:

bash
docker compose -f local/docker-compose.yml up -d --wait keycloak
bash
docker compose -f local/docker-compose.yml up -d --wait keycloak
powershell
docker compose -f local/docker-compose.yml up -d --wait keycloak

You should see Container kims-v2-keycloak-1 Healthy. The first start takes about a minute. Compose starts Postgres first if it isn't running, because Keycloak waits for it to be healthy.

It answers on http://localhost:8180. The admin console is http://localhost:8180/admin; its user name and password are KC_BOOTSTRAP_ADMIN_USERNAME and KC_BOOTSTRAP_ADMIN_PASSWORD in local/docker-compose.yml.

#2. What the realm import gives you

Nothing to run. Keycloak starts with --import-realm and reads local/keycloak/kims-realm.json from the mounted local/keycloak folder:

What Value
Realm kims
Client kims-cms, confidential, standard flow, PKCE S256. Its secret is KEYCLOAK_CLIENT_SECRET in .env.local
Redirect URIs http://localhost:3101/* (CMS on your machine). The windows-fixes branch adds http://localhost:3102/* for the CMS on kind
Back-channel logout URL http://host.docker.internal:3101/api/auth/backchannel-logout, session required
Client role cms-access: only people with it can use the CMS
Tokens and sessions 300 s access token, 30 min idle, 10 h maximum, refresh tokens rotated

The import happens only when the realm doesn't exist yet. A change to kims-realm.json needs Keycloak's database emptied first: see Stop and reset.

#3. The test users

Also from kims-realm.json, all with one password, which is in that file:

User Has cms-access Used for
admin@kims.local Yes The first CMS Admin, through KIMS_BOOTSTRAP_ADMINS
editor@kims.local Yes Editing and submitting for review
reviewer@kims.local Yes Approving
outsider@kims.local No Checking that people without the role are refused

cms-access only lets a person in. What they can do is set on the CMS's People screen (Run the apps).

#4. Check the realm answers

bash
curl -s http://localhost:8180/realms/kims/.well-known/openid-configuration | head -c 120; echo
bash
curl -s http://localhost:8180/realms/kims/.well-known/openid-configuration | head -c 120; echo
powershell
curl.exe -s http://localhost:8180/realms/kims/.well-known/openid-configuration

You should see JSON starting {"issuer":"http://localhost:8180/realms/kims".

#How Keycloak reaches the CMS on your machine

For back-channel logout, Keycloak (in a container) calls the CMS at host.docker.internal:3101. The Compose file adds host.docker.internal:host-gateway to the Keycloak container, so this name resolves on Linux Docker Engine too, not only in Docker Desktop.

Note

On Linux, the call arrives on the Docker bridge's gateway address, not on 127.0.0.1. The CMS dev server listens on every interface, so it receives it, unless a host firewall (for example ufw) blocks traffic from the Docker bridge. If it does, signing out in Keycloak ends the CMS session only at the next 5-minute refresh, not at once. This was not tried on Linux.

#The repo's own shortcut: npm run dev:up

The repo has its own one-liner that starts all three services, creates the buckets and runs the migrations (it does not load the bundle). Run from the repo:

bash
npm run dev:up
bash
npm run dev:up
powershell
npm run dev:up

It ends with:

text
[dev:up] ready
  Postgres  127.0.0.1:5418  (db kims)
  Keycloak  http://localhost:8180  (realm kims)
  S3        http://127.0.0.1:9100  (buckets kims-assets, kims-website)

npm run dev:up -- --jenkins starts Jenkins as well. It worked on Windows on 2026-11-26. It is plain Node, so it should behave the same on Linux and macOS.

#Check all three

Run from the repo:

bash
docker compose -f local/docker-compose.yml ps
bash
docker compose -f local/docker-compose.yml ps
powershell
docker compose -f local/docker-compose.yml ps

You should see postgres, keycloak and s3, each running and (healthy).

Check Command (from the repo) You should see
S3 answers curl -s -o /dev/null -w "%{http_code}" http://127.0.0.1:9100/healthz (Windows: curl.exe ... -o NUL ...) 200
Postgres answers docker compose -f local/docker-compose.yml exec -T postgres pg_isready -U kims -d kims accepting connections
Keycloak realm the discovery URL above "issuer":"http://localhost:8180/realms/kims"
A service's log docker compose -f local/docker-compose.yml logs --tail 50 <service> Its last 50 lines

#If it goes wrong

What you see Likely cause What to do
Bind for 127.0.0.1:9100 failed: port is already allocated (or 5418, 8180) Something else uses the port Find it: Troubleshooting, stop it, run the step again
s3 waits, then unhealthy Docker short of disk, so SeaweedFS can't start its volume servers Free disk (Docker Desktop: Settings, Resources; Linux: docker system df), then docker compose -f local/docker-compose.yml logs s3
local-buckets.mjs fails with ECONNREFUSED The stand-in isn't up yet Start it (step 1) and wait for Healthy
local-buckets.mjs fails with ASSETS_BUCKET and WEBSITE_BUCKET must be set .env.local is missing them Compare with local/.env.example
local-buckets.mjs fails with Cannot find package '@aws-sdk/client-s3' npm install not run in the repo Run it
Keycloak stays starting, then unhealthy It can't reach its database Check Postgres is healthy, then docker compose -f local/docker-compose.yml logs keycloak
Discovery URL gives 404, Realm does not exist The realm wasn't imported Look in the Keycloak log. Realm 'kims' already exists. Import skipped means its database has an older copy: Stop and reset
A change to kims-realm.json doesn't show The import runs only when the realm is missing Same as above
permission denied while trying to connect to the Docker daemon socket (Linux) Your user isn't in the docker group sudo usermod -aG docker $USER, then sign out and in. See Docker
Errors mentioning dockerDesktopLinuxEngine (Windows) Docker Desktop isn't running Start it and wait
no matching manifest for linux/arm64 on Apple silicon An image without an arm64 build Not seen on this project; if it happens, add platform: linux/amd64 to that service in a local copy of the Compose file and run under Rosetta emulation

#Sources

Built 2026-11-29. Commands are shown for the system picked at the top; every block has all three.