Skip to content

Commit 5e9d2c1

Browse files
committed
fix(dev-k8s): resolve Dockerfile.dev from smartem-decisions, refresh devops skill
dev-k8s.sh `ensure_local_image` invoked `docker build -f Dockerfile.dev` from $PROJECT_ROOT (smartem-devtools), but Dockerfile.dev lives in smartem-decisions. The build failed with "no such file or directory" on every fresh `up`, leaving operators to discover the workaround themselves. Introduce SMARTEM_DECISIONS_PATH, defaulting to a sibling checkout next to smartem-devtools. Fail fast with a clear message when the file is missing so non-standard layouts can be configured rather than silently broken. Refresh the devops skill in the same change: the script path moved to smartem-devtools, the dev stack now ships an in-cluster Keycloak (with the docker-compose mock kept as the FE-only fallback), and the build command in the skill's container section matches what dev-k8s.sh expects.
1 parent d8dfd75 commit 5e9d2c1

2 files changed

Lines changed: 28 additions & 5 deletions

File tree

claude-code/shared/skills/devops/SKILL.md

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,12 @@ If you encounter this error, advise the user to run the above command. Other per
3939

4040
**Cluster management:**
4141

42+
The `dev-k8s.sh` orchestration script lives in **smartem-devtools** (it used to live in smartem-decisions). It needs a sibling checkout of `smartem-decisions` to build the backend image from `Dockerfile.dev`; override `SMARTEM_DECISIONS_PATH` if your layout differs.
43+
4244
```bash
43-
cd repos/DiamondLightSource/smartem-decisions
45+
cd repos/DiamondLightSource/smartem-devtools
4446

45-
# Start local k3s cluster with all services
47+
# Start local k3s cluster with all services (backend, postgres, rabbitmq, mongo, es, keycloak mock, FE)
4648
./scripts/k8s/dev-k8s.sh up
4749

4850
# Stop and cleanup
@@ -53,6 +55,12 @@ kubectl get pods -n smartem-decisions
5355
kubectl get services -n smartem-decisions
5456
```
5557

58+
**Keycloak in the dev stack:**
59+
60+
The in-cluster Keycloak mock (`keycloak-mock/keycloak.yaml`, pulled in via the development kustomization) is the primary local auth provider. It is brought up automatically by `dev-k8s.sh up` and reachable at `http://localhost:30090`.
61+
62+
The `keycloak-mock/docker-compose.yml` in the same directory is a **fallback for FE-only development** — use it when working inside `smartem-frontend` in isolation without the rest of the k3s stack. Do not run both at once or the NodePort/host-port mapping will collide.
63+
5664
### Services (smartem-decisions namespace)
5765

5866
| Service | Port | NodePort | Purpose |
@@ -77,7 +85,10 @@ k8s/
7785
```bash
7886
cd repos/DiamondLightSource/smartem-decisions
7987

80-
# Build backend image
88+
# Build local dev backend image (matches what dev-k8s.sh expects)
89+
docker build -f Dockerfile.dev -t smartem-decisions:latest .
90+
91+
# Build production image
8192
docker build -t smartem-backend:dev .
8293

8394
# Build with specific Python version (from Dockerfile)
@@ -87,6 +98,8 @@ docker build --build-arg PYTHON_VERSION=3.12 -t smartem-backend:dev .
8798
docker build --target production -t smartem-backend:prod .
8899
```
89100

101+
`dev-k8s.sh up` will build `smartem-decisions:latest` automatically if it is missing, loading it into k3s containerd. Pre-build it manually only if you want to iterate without re-running `up`.
102+
90103
### Push to Registry
91104

92105
```bash

scripts/k8s/dev-k8s.sh

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ NAMESPACE="smartem-decisions"
66
K8S_ENV_PATH="k8s/environments/development"
77
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
88
PROJECT_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)"
9+
# smartem-decisions repo holds Dockerfile.dev for the local backend image build.
10+
# Override SMARTEM_DECISIONS_PATH if your checkout layout is not the conventional sibling.
11+
SMARTEM_DECISIONS_PATH="${SMARTEM_DECISIONS_PATH:-$PROJECT_ROOT/../smartem-decisions}"
912
DEPLOY_ENV="${DEPLOY_ENV:-development}"
1013

1114
# Colors for output
@@ -380,9 +383,16 @@ ensure_local_image() {
380383

381384
# Check if image exists in Docker
382385
if ! docker image inspect "$image_name" &> /dev/null; then
383-
log_info "Building SmartEM image..."
384-
cd "$PROJECT_ROOT"
386+
if [[ ! -f "$SMARTEM_DECISIONS_PATH/Dockerfile.dev" ]]; then
387+
log_error "Dockerfile.dev not found at: $SMARTEM_DECISIONS_PATH/Dockerfile.dev"
388+
log_error "Set SMARTEM_DECISIONS_PATH to the smartem-decisions repo checkout, or"
389+
log_error "clone it as a sibling of smartem-devtools."
390+
exit 1
391+
fi
392+
log_info "Building SmartEM image from $SMARTEM_DECISIONS_PATH..."
393+
cd "$SMARTEM_DECISIONS_PATH"
385394
docker build -f Dockerfile.dev -t "$image_name" .
395+
cd "$PROJECT_ROOT"
386396
else
387397
log_info "SmartEM image already exists in Docker"
388398
fi

0 commit comments

Comments
 (0)