Skip to content

Commit 318103d

Browse files
author
Nils Bars
committed
Add recreate subcommand to ctrl.sh
Builds and force-recreates containers in one step, avoiding stale container issues when image contents change. Update CLAUDE.md with new deployment workflow.
1 parent 9ee007d commit 318103d

2 files changed

Lines changed: 24 additions & 7 deletions

File tree

.claude/CLAUDE.md

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,12 @@ The test infrastructure (`tests/helpers/ref_instance.py`) automatically sets thi
2424
./ctrl.sh build
2525

2626
# Start services
27-
# For development, always use --debug and --hot-reloading:
28-
# --debug enables Flask debug mode and verbose logging
29-
# --hot-reloading enables Flask auto-reload and runs the spa-frontend
30-
# under `vite dev` (Vite HMR) instead of a static build
31-
./ctrl.sh up --debug --hot-reloading
32-
./ctrl.sh up # production-style start, no HMR
27+
./ctrl.sh up --debug # debug mode, no HMR
28+
29+
# Rebuild and recreate specific services (e.g. after code changes):
30+
./ctrl.sh recreate frontend-proxy # SPA changes
31+
./ctrl.sh recreate web # webapp changes
32+
./ctrl.sh recreate frontend-proxy web # both
3333

3434
# Stop services
3535
./ctrl.sh stop # Keep containers
@@ -209,6 +209,10 @@ Client (ssh exercise@host -p 2222)
209209
- `/data/ssh-proxy/` - SSH proxy state
210210
- `/data/log/` - Application logs
211211

212+
## Data Directory
213+
214+
Never create, edit, or delete files under `data/` unless explicitly asked by the user. This directory contains live exercise definitions, student data, and database files. The exercise import path is configured in `settings.yaml` (default: `ref/exercises`).
215+
212216
## Code Comments
213217

214218
- Do not reference line numbers in comments (e.g., "see ssh.py lines 397-404"). Line numbers change frequently and become outdated. Reference functions, classes, or use direct code references instead.

ctrl.sh

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,11 @@ Commands:
7575
restart
7676
Restart all services (disconnects currently connected users).
7777
78+
recreate [SERVICE...]
79+
Rebuild and recreate containers from the new images. Use this
80+
instead of restart when image contents changed (e.g. SPA or
81+
webapp code).
82+
7883
restart-web
7984
Restart only the web interface (users stay connected via SSH).
8085
@@ -349,7 +354,7 @@ function build {
349354
(
350355
info "=> Building docker base image"
351356
cd 'ref-docker-base'
352-
./build.sh "$@"
357+
./build.sh
353358
)
354359
(
355360
info "=> Building release container"
@@ -454,6 +459,11 @@ function restart {
454459
execute_cmd $DOCKER_COMPOSE --env-file $ENV_SETTINGS_FILE -p ref restart "$@"
455460
}
456461

462+
function recreate {
463+
execute_cmd $DOCKER_COMPOSE --env-file $ENV_SETTINGS_FILE -p ref build "$@"
464+
execute_cmd $DOCKER_COMPOSE --env-file $ENV_SETTINGS_FILE -p ref up -d --force-recreate "$@"
465+
}
466+
457467
function ps {
458468
execute_cmd $DOCKER_COMPOSE --env-file $ENV_SETTINGS_FILE -p ref ps "$@"
459469
}
@@ -503,6 +513,9 @@ case "$cmd" in
503513
restart)
504514
restart "$@"
505515
;;
516+
recreate)
517+
recreate "$@"
518+
;;
506519
restart-web)
507520
restart web "$@"
508521
;;

0 commit comments

Comments
 (0)