chore: devcontainer pre-creates as vscode, resilient postStart script

This commit is contained in:
Jonas Miederer 2026-09-07 05:04:41 +00:00
parent 0a2b73f3b4
commit 74831483eb
3 changed files with 28 additions and 4 deletions

View file

@ -27,9 +27,14 @@ RUN uv python install 3.12 \
# Trust the workspace bind mount (source on Windows FS -> uid mismatch)
RUN git config --system --add safe.directory /workspaces/kirche-einfach
# Pre-create named-volume targets (volumes inherit image content on first mount)
RUN mkdir -p /workspaces/kirche-einfach/backend/.venv \
/workspaces/kirche-einfach/frontend/node_modules
# Pre-create named-volume targets (volumes inherit image content on first mount).
# The backend venv is created as `vscode` so VS Code's Python extension finds an
# interpreter immediately on first attach, before postCreateCommand runs `uv sync`.
USER vscode
RUN mkdir -p /workspaces/kirche-einfach/backend \
&& uv venv /workspaces/kirche-einfach/backend/.venv \
&& mkdir -p /workspaces/kirche-einfach/frontend/node_modules
USER root
# opencode (as non-root user)
USER vscode

View file

@ -13,7 +13,7 @@
"overrideCommand": false,
"workspaceFolder": "/workspaces/kirche-einfach",
"postCreateCommand": "sudo -E bash .devcontainer/setup.sh",
"postStartCommand": "mkdir -p ~/.ssh && cp /mnt/host-ssh/id_rsa /mnt/host-ssh/id_rsa.pub ~/.ssh/ && cp /mnt/host-ssh/known_hosts ~/.ssh/ 2>/dev/null; ssh-keyscan -t ed25519,rsa gitlab.jonas-miederer.com >> ~/.ssh/known_hosts 2>/dev/null; chmod 700 ~/.ssh && chmod 600 ~/.ssh/id_rsa && chmod 644 ~/.ssh/id_rsa.pub ~/.ssh/known_hosts",
"postStartCommand": "bash .devcontainer/postStart.sh",
"customizations": {
"vscode": {
"extensions": [

View file

@ -0,0 +1,19 @@
#!/bin/bash
# Post-start hook: copies SSH keys from the host into the container, then
# adds the git host. Never fails the devcontainer run: any missing file on
# the host (e.g. no id_rsa) must not abort the lifecycle command.
set -u
mkdir -p ~/.ssh
for f in id_rsa id_rsa.pub known_hosts; do
cp -f "/mnt/host-ssh/$f" ~/.ssh/ 2>/dev/null || true
done
ssh-keyscan -t ed25519,rsa gitlab.jonas-miederer.com >> ~/.ssh/known_hosts 2>/dev/null || true
chmod 700 ~/.ssh 2>/dev/null || true
chmod 600 ~/.ssh/id_rsa 2>/dev/null || true
chmod 644 ~/.ssh/id_rsa.pub ~/.ssh/known_hosts 2>/dev/null || true
exit 0