Skip to content

Commit 946434d

Browse files
author
Nils Bars
committed
Drop the ref-docker-base/container-keys mirror copy
Container SSH keys are bind-mounted into web and ssh-reverse-proxy at runtime and re-mounted into student containers from there. The base-image Dockerfile no longer copies them in, so the per-deployment mirror under ref-docker-base/container-keys is unused. Remove the copy in prepare.py and the test-helper equivalent, drop the gitignore entry, and refresh docs/CONFIG.md.
1 parent 6574b7a commit 946434d

4 files changed

Lines changed: 8 additions & 19 deletions

File tree

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ webapp/venv
2020
webapp/ref_webapp.egg-info/
2121

2222
ref-docker-base/task-wrapper
23-
ref-docker-base/container-keys
2423

2524
container-keys/
2625

docs/CONFIG.md

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,9 @@ Downstream rendering steps (run in both modes):
6363
`testing=False` / `bridge_id=""` are the only values still hard-coded in
6464
`prepare.py`.
6565
3. `generate_ssh_keys()` creates ed25519 SSH host keys in `container-keys/`
66-
if missing (existing keys are left alone) and mirrors them into
67-
`ref-docker-base/container-keys/` for the base image build.
66+
if missing (existing keys are left alone). At runtime the directory is
67+
bind-mounted into `web` and `ssh-reverse-proxy`; `web` in turn mounts the
68+
`.pub` files into student containers at `/etc/ssh/master_keys/{user,root}`.
6869

6970
`ctrl.sh` handles the first-run case automatically: if neither
7071
`settings.yaml` nor `settings.env` exists, it invokes `./prepare.py` before
@@ -262,9 +263,10 @@ config dataclass.
262263
flag, compose falls back to its default `.env` lookup, finds nothing, and
263264
every `${VAR:?...}` placeholder fails. Always go through `ctrl.sh`, or
264265
replicate its `--env-file` / shell-export pattern manually.
265-
- **`container-keys/` and `ref-docker-base/container-keys/` must stay in
266-
sync.** `prepare.py` copies the former into the latter so the base image
267-
build picks them up. If you rotate the host keys, re-run `./prepare.py`
268-
or rebuild the base image.
266+
- **`container-keys/` is bind-mounted live into student containers.**
267+
Rotating the files on the host takes effect on the next student container
268+
start — no image rebuild needed. The `web` container mounts the directory
269+
read-only and re-mounts the `.pub` files into each student container at
270+
`/etc/ssh/master_keys/{user,root}`.
269271
- **`settings.yaml` and `settings.env` are mode `0600` by design.** Do not
270272
loosen the permissions — they contain plaintext secrets.

prepare.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515

1616
import argparse
1717
import secrets
18-
import shutil
1918
import subprocess
2019
import sys
2120
from pathlib import Path
@@ -30,7 +29,6 @@
3029
COMPOSE_TEMPLATE = "docker-compose.template.yml"
3130
COMPOSE_OUT = REPO_ROOT / "docker-compose.yml"
3231
CONTAINER_KEYS_DIR = REPO_ROOT / "container-keys"
33-
DOCKER_BASE_KEYS_DIR = REPO_ROOT / "ref-docker-base" / "container-keys"
3432

3533
SECRET_BYTES = 32
3634

@@ -323,8 +321,6 @@ def generate_ssh_keys() -> None:
323321
["ssh-keygen", "-t", "ed25519", "-N", "", "-f", str(key_path)]
324322
)
325323

326-
shutil.copytree(CONTAINER_KEYS_DIR, DOCKER_BASE_KEYS_DIR, dirs_exist_ok=True)
327-
328324

329325
def parse_args() -> argparse.Namespace:
330326
parser = argparse.ArgumentParser(description=__doc__)

tests/helpers/ref_instance.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -472,7 +472,6 @@ def _find_free_subnets(self, count: int) -> List[tuple[str, str]]:
472472
def _generate_ssh_keys(self):
473473
"""Generate SSH keys needed for container communication."""
474474
container_keys_dir = self._ref_root / "container-keys"
475-
ref_docker_base_keys = self._ref_root / "ref-docker-base" / "container-keys"
476475

477476
container_keys_dir.mkdir(parents=True, exist_ok=True)
478477

@@ -485,13 +484,6 @@ def _generate_ssh_keys(self):
485484
capture_output=True,
486485
)
487486

488-
# Copy keys to ref-docker-base if it exists
489-
if ref_docker_base_keys.parent.exists():
490-
ref_docker_base_keys.mkdir(parents=True, exist_ok=True)
491-
for key_file in container_keys_dir.iterdir():
492-
if key_file.name != ".gitkeep":
493-
shutil.copy2(key_file, ref_docker_base_keys / key_file.name)
494-
495487
def _write_config_files(self):
496488
"""Write the configuration files."""
497489
# Generate SSH keys if they don't exist

0 commit comments

Comments
 (0)