| To | Quick way, from <KIMS_FOLDER> |
Keeps the data |
|---|---|---|
| Stop the apps | Ctrl+C in the apps start window, or in each app's window |
Yes |
| Stop Postgres, Keycloak, S3 and Jenkins | node deployment-steps/scripts/deploy.mjs local down |
Yes |
| Delete the kind cluster | node deployment-steps/scripts/deploy.mjs local kube down |
Yes: no data lives in the cluster |
| Make Keycloak import the realm file again | By hand, below | Everything except Keycloak's users and sessions |
| Delete everything and start again | node deployment-steps/scripts/deploy.mjs local reset, then the same with --yes |
No |
The commands are the same on Linux, macOS and Windows (PowerShell). local reset on its own only lists what it would delete, with sizes; it deletes only with --yes.
#Stop
#1. Stop the apps
Press Ctrl+C in the apps start window (or in each app's own window, if you started them by hand: Apps). Do this first, or the apps log connection errors when the services go.
On Windows, local apps start stops each app's whole process tree on Ctrl+C. On macOS and Linux it sends SIGTERM; if a port is still in use afterwards (3100 or 3101), see Port already in use.
#2. Stop the services
Quick way, from <KIMS_FOLDER>:
node deployment-steps/scripts/deploy.mjs local downnode deployment-steps/scripts/deploy.mjs local downnode deployment-steps/scripts/deploy.mjs local downIt ends OK: the local services are stopped. Their data is kept; local up starts them again.
By hand, from the repo (<KIMS_FOLDER>/repos/kims-v2):
docker compose -f local/docker-compose.yml --profile jenkins downdocker compose -f local/docker-compose.yml --profile jenkins downdocker compose -f local/docker-compose.yml --profile jenkins downIt removes the containers, Jenkins included if it was running. The data stays in the Docker volumes, so local up (or Services) brings everything back as it was.
#3. Delete the kind cluster
Quick way: node deployment-steps/scripts/deploy.mjs local kube down from <KIMS_FOLDER>. By hand, from any folder:
kind delete cluster --name kims-v2kind delete cluster --name kims-v2kind delete cluster --name kims-v2It prints Deleting cluster "kims-v2" .... Nothing in the cluster needs keeping: the data is in the local Postgres and S3. kind and Helm rehearsal makes it again (local kube up takes about a minute with --skip-build if the image is still in Docker; after a delete it must be loaded again, which kube up does).
#Empty only Keycloak's database
Keycloak reads local/keycloak/kims-realm.json only on its first start, into an empty keycloak database. After that file changes (a new redirect address, a new test user), empty Keycloak's database so it imports the file again. This deletes Keycloak's users and sessions, and nothing else: the kims database (content, CMS people, jobs) is untouched. CMS people are matched to Keycloak users by email, so they sign in again as before.
Run each from the repo (<KIMS_FOLDER>/repos/kims-v2). The commands are the same in all three shells.
#1. Stop Keycloak
docker compose -f local/docker-compose.yml stop keycloak#2. Drop and recreate its database
docker compose -f local/docker-compose.yml exec -T postgres psql -U kims -d postgres -c "drop database keycloak with (force)" -c "create database keycloak"You should see DROP DATABASE then CREATE DATABASE. The kims user is the Compose database user, which needs no password from inside the container.
#3. Start Keycloak
docker compose -f local/docker-compose.yml up -d --wait keycloakIt takes about a minute. Then docker compose -f local/docker-compose.yml logs keycloak shows the realm kims being imported, and the test users from the realm file can sign in again (Services).
#Reset
Deletes all local data, to start again from the handover. It can't be undone.
| What goes | Where it lives |
|---|---|
The database: every CMS edit, CMS people, jobs, build history, Keycloak's users, kims_rehearsal |
Docker volume kims-v2_postgres-data |
| The media library and the built website in the buckets | Docker volume kims-v2_s3-data |
| Jenkins's jobs, credentials and history | Docker volume kims-v2_jenkins-home |
| Jenkins's build workspaces (up to about 10 GB) | .local-jenkins-workspace in the repo on main; Docker volume kims-v2_jenkins-workspace with the windows-fixes commits |
| The kind cluster | kind |
| The generated files: content snapshot, media manifest and images, site build files, the built website (about 5 GB) | .local-content, apps/website/media-manifest.json, apps/website/public/media, .site-build, apps/website/dist in the repo |
| The copy of a Jenkins build you took out (Local Jenkins, about 4 GB) | <KIMS_FOLDER>/jenkins-site-dist (not deleted by local reset: delete it by hand) |
What stays: the code, .env.local, the handover zip and its extracted folder, and the Docker images.
#Quick way
From <KIMS_FOLDER>, first see what would go:
node deployment-steps/scripts/deploy.mjs local resetnode deployment-steps/scripts/deploy.mjs local resetnode deployment-steps/scripts/deploy.mjs local resetIt lists the kims-v2_ volumes, the cluster and each generated file with its size, deletes nothing, and exits with code 3 and nothing deleted ... Run it again with --yes to go ahead. That exit is expected. Then:
node deployment-steps/scripts/deploy.mjs local reset --yesnode deployment-steps/scripts/deploy.mjs local reset --yesnode deployment-steps/scripts/deploy.mjs local reset --yesIt runs docker compose ... --profile jenkins down --volumes, deletes the cluster, then each generated file, but only after git check-ignore confirms it is gitignored (anything that isn't is left alone, with a warning). It ends OK: the local setup is reset.
#By hand
#1. Stop the apps
As in Stop.
#2. Delete the services and their volumes
From the repo:
docker compose -f local/docker-compose.yml --profile jenkins down --volumesThe same in all three shells.
#3. Delete the kind cluster
As in Stop, step 3.
#4. Delete the generated files
From the repo. All of these are gitignored, so nothing git tracks is touched.
rm -rf .local-content apps/website/media-manifest.json apps/website/public/media .site-build apps/website/dist .local-jenkins-workspace ../../jenkins-site-distrm -rf .local-content apps/website/media-manifest.json apps/website/public/media .site-build apps/website/dist .local-jenkins-workspace ../../jenkins-site-distRemove-Item -Recurse -Force .local-content, apps/website/media-manifest.json, apps/website/public/media, .site-build, apps/website/dist, .local-jenkins-workspace, ../../jenkins-site-dist -ErrorAction SilentlyContinueOn Linux, files the Jenkins container wrote into .local-jenkins-workspace may belong to another user; if rm says Permission denied, run that one path with sudo rm -rf.
#5. Start again
node deployment-steps/scripts/deploy.mjs local up (starts the services and seeds the database from the bundle again), then local apps prepare. See Services and Apps.
#Check
| Check | Folder | Command | You should see |
|---|---|---|---|
| Nothing running | the repo | docker compose -f local/docker-compose.yml --profile jenkins ps |
No services listed |
| No cluster | any | kind get clusters |
No kind clusters found. |
| After a reset, no data left | any | docker volume ls --filter name=kims-v2_ |
No volumes listed |
| After a reset, no generated files | the repo | git status --ignored --short |
None of the paths in step 4 |
#If it goes wrong
| What you see | Likely cause | What to do |
|---|---|---|
local down says still running: ... |
A container didn't stop in time | docker compose -f local/docker-compose.yml ps in the repo, then stop it in Docker Desktop or with docker stop |
Remove-Item or rm says a file is in use (Windows) |
An app or editor still has it open | Stop the apps and close the folder in your editor, then step 4 again |
local reset --yes ends not everything was deleted: ... |
Same, or a container outside Compose uses a volume | Close what uses the files; docker volume ls --filter name=kims-v2_ and remove the volume in Docker Desktop; run it again |
local reset warns ... isn't gitignored, so it's left alone |
The repo's .gitignore changed |
Nothing: it protects tracked files. Delete the path by hand only if you are sure |
drop database keycloak says it is being accessed |
Keycloak still running (or with (force) left out) |
Stop Keycloak first, then the command as written |
| Keycloak starts but the realm is the old one | Its database wasn't emptied, or a different volume was used | Empty only Keycloak's database again; check docker compose ... logs keycloak for the import |
#Sources
kims-v2/local/docker-compose.yml,kims-v2/local/postgres/init.sql,kims-v2/local/keycloak/kims-realm.json,kims-v2/.gitignore(branchmain;local/docker-compose.ymlonwindows-fixesfor thejenkins-workspacevolume)deployment-steps/local/08-stop-and-reset.md;scripts/commands/local/down.mjs,reset.mjs,kube-down.mjsdocker compose down: https://docs.docker.com/reference/cli/docker/compose/down/kind delete cluster: https://kind.sigs.k8s.io/docs/user/quick-start/#deleting-a-cluster- PostgreSQL
DROP DATABASE ... WITH (FORCE): https://www.postgresql.org/docs/current/sql-dropdatabase.html - Keycloak realm import at start-up: https://www.keycloak.org/server/importExport