KKIMS on-site docs
Local rehearsal

The local env file (.env.local)

Create .env.local from local/.env.example, and know what every value in it is, what it must match, and what later steps add to it.

.env.local sits at the root of the repo and holds the settings every local command reads: the database address, Keycloak, the S3 stand-in, the app addresses and two app secrets. It is gitignored, so it never reaches Git.

The repo ships a ready-made copy, local/.env.example, whose values match the Compose stand-ins exactly. You don't need to edit it.

Warning

Every value in it is a local test value. None of them works on KIMS, and none may be copied into the Helm values or a Kubernetes Secret. KIMS's values come from Configuration and Secrets.

#Create it

#1. Check whether it exists

Run from the repo (<KIMS_FOLDER>/repos/kims-v2):

bash
test -f .env.local && echo exists || echo missing
bash
test -f .env.local && echo exists || echo missing
powershell
Test-Path .env.local

You should see exists (or True), or missing (or False). If it exists, skip step 2.

#2. Copy the example

Run from the repo:

bash
cp local/.env.example .env.local
bash
cp local/.env.example .env.local
powershell
Copy-Item local/.env.example .env.local

It prints nothing.

Tip

npm run dev:up (the repo's own shortcut, see Services) also copies the example when .env.local is missing, and prints [dev:up] wrote .env.local from local/.env.example. It doesn't matter which you do first.

#3. Check it is readable

Open it in an editor and check it has plain KEY=value lines. On Windows, an editor that saves it as UTF-16 breaks Node's --env-file: save it as UTF-8.

#What is in it

The values are not repeated here: open the file to see them. The local passwords and keys are in it, and in the files the table names.

#Database

Setting What it is Must match
DATABASE_URL postgres://kims:<LOCAL_DB_PASSWORD>@127.0.0.1:5418/kims POSTGRES_USER, POSTGRES_PASSWORD and the published port 5418 of the postgres service in local/docker-compose.yml
DATABASE_URL_TEST The same server, database postgres Only the integration tests use it: they create and drop kims_test_* databases there

#Keycloak

Setting What it is Must match
KEYCLOAK_ISSUER http://localhost:8180/realms/kims The issuer the realm reports, character for character, or every sign-in is refused
KEYCLOAK_CLIENT_ID kims-cms The client in local/keycloak/kims-realm.json
KEYCLOAK_CLIENT_SECRET The client's secret That client's secret in local/keycloak/kims-realm.json
KIMS_BOOTSTRAP_ADMINS admin@kims.local A test user in kims-realm.json. It becomes the first CMS Admin on first sign-in, while the CMS has no people

KEYCLOAK_ACCESS_ROLE is not in the file: it defaults to cms-access. Don't add it unless you want to test a different role.

#S3 stand-in

Setting What it is Must match
S3_ENDPOINT http://127.0.0.1:9100 The port the s3 service publishes
S3_REGION ap-south-1 Nothing locally
S3_FORCE_PATH_STYLE true Needed for the stand-in; never set on EKS
AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY The stand-in's own identity The kims identity in local/s3/s3.json
ASSETS_BUCKET, WEBSITE_BUCKET kims-assets, kims-website Nothing: the buckets are created with these names. s3.json lets anyone read kims-website
Warning

The AWS keys in this file are for the local stand-in only. If your shell also has real AWS credentials (an AWS_PROFILE or SSO session for KIMS), the local commands still use the stand-in, because S3_ENDPOINT points them there. Never put real AWS keys in .env.local.

#Addresses

Setting What it is Must match
CMS_URL http://localhost:3101 The port the CMS runs on, and the kims-cms client's redirect URIs (http://localhost:3101/*)
SITE_URL http://localhost:9100/kims-website The website bucket on the stand-in. The site build writes it into canonical links and the sitemap

#App secrets

Setting What it is Rules
SESSION_SECRET Signs the session cookie and encrypts stored Keycloak refresh tokens At least 32 characters. Changing it signs everybody out
SECRETS_KEY Encrypts the Google secrets stored in the database (translation key, reviews sign-in) 32 bytes, base64. Changing it makes any stored Google secret unreadable
Note

The kind cluster does not use this SECRETS_KEY: its kims-app Secret gets a fixed throwaway key from deploy/kind/up.sh (and deploy.mjs). So a Google secret saved through the CMS on 3101 can't be read by the CMS on kind, and the other way round. Both use the same database.

#What later pages add

Page Adds Why
Jenkins JENKINS_JOB_URL, JENKINS_USER, JENKINS_TOKEN So a publish in the CMS on 3101 starts a build in the local Jenkins
Site build (optional, windows-fixes only) KIMS_BUILD_WORKERS Fewer static-generation workers if the build runs out of memory. main ignores it

Restart the CMS and worker after any change: they read the file only when they start.

#Who reads it, and how

Reader How
npm run db:migrate, content:export, media:manifest, site:build node --env-file-if-exists=.env.local in the root package.json
scripts/local-buckets.mjs, scripts/handover/data-bundle.mjs node --env-file=.env.local on the command line
The CMS apps/cms loads it through scripts/with-root-env.mjs with npm run dev; deploy.mjs passes the values in directly
The worker --env-file-if-exists=../../.env.local
deploy.mjs Reads it itself (scripts/lib/env.mjs), and hides the secret values in its screen output and logs
deploy/kind/up.sh and deploy.mjs local kube up Turn it into the kind Secrets, with 127.0.0.1 and localhost replaced by host.docker.internal

Real environment variables in your shell win over the file for Node's --env-file. If a value seems ignored, check you haven't exported the same name in your shell profile.

#If you change a port or a secret

If you change a port in local/docker-compose.yml, or a secret in local/keycloak/kims-realm.json or local/s3/s3.json, change the same value here. A change to kims-realm.json also needs Keycloak's database emptied before it takes effect: see Stop and reset.

#Check

Check Run from Command You should see
It exists the repo test -f .env.local && echo exists (PowerShell: Test-Path .env.local) exists (True)
deploy.mjs can read it <KIMS_FOLDER> node deployment-steps/scripts/deploy.mjs local check --for 01 .env.local: OK in the table

#If it goes wrong

What you see Likely cause What to do
node: .env.local: not found Run from the wrong folder Run from the repo root
ASSETS_BUCKET and WEBSITE_BUCKET must be set Lines missing, or the file is UTF-16 Compare with local/.env.example; save as UTF-8
Every sign-in refused KEYCLOAK_ISSUER differs from what Keycloak reports (a trailing /, 127.0.0.1 instead of localhost) Copy it from local/.env.example
Google secrets saved earlier can no longer be read SECRETS_KEY changed Put the old value back, or enter the Google secrets again in the CMS

#Sources

  • kims-v2/local/.env.example (identical on main and windows-fixes), kims-v2/local/docker-compose.yml, kims-v2/local/keycloak/kims-realm.json, kims-v2/local/s3/s3.json
  • kims-v2/docs/CONFIG.md, kims-v2/package.json, kims-v2/scripts/dev-up.mjs, kims-v2/deploy/kind/up.sh
  • deployment-steps/local/00-prerequisites.md (step 10), scripts/lib/env.mjs
  • Node.js --env-file: https://nodejs.org/api/cli.html#--env-filefile
Built 2026-11-29. Commands are shown for the system picked at the top; every block has all three.