---
name: codeserver-setup-scripts
description: "Two bash scripts at /config/workspace/codeserver-setup/ rehydrate the code-server container with dev tooling and VS Code extensions after a redeploy. Idempotent, run from the Docker host as root."
metadata: 
  node_type: memory
  type: project
  originSessionId: af4730c8-75f2-46b3-bc7c-204632e015b0
---

The user maintains a "rehydrate after redeploy" pattern for the code-server container instead of building a custom Docker image. Two scripts on the bind mount:

- **`/config/workspace/codeserver-setup/install.sh`** — system packages: PHP 8.3 CLI + extensions, Composer, MariaDB client, ripgrep, fd-find, shellcheck, PHPStan PHAR, phpcs/phpcbf PHARs. Runs `apt-get install` so requires root.
- **`/config/workspace/codeserver-setup/extensions.sh`** — VS Code extensions (Claude, GitLens, Git Graph, gitblame, indent-rainbow, Intelephense, PHPStan-vscode, shellcheck, sqltools + mysql driver, dotenv) and a `jq`-based merge into `/config/data/User/settings.json`. Accepts root invocation and re-execs itself as `abc` via `runuser`.

**Why:** Keeps the upstream linuxserver/code-server image untouched. Fast redeploys, no Dockerfile to maintain, all configuration lives in the user's bind mount so it survives container recreates. Trades a one-time rehydrate step for image-management overhead.

**How to apply:**
- Both scripts are idempotent — safe to re-run on every redeploy or whenever the user wants to refresh.
- Invocation from the Docker host (both use the same pattern):
  ```
  docker exec -u root <container> bash /config/workspace/codeserver-setup/install.sh
  docker exec -u root <container> bash /config/workspace/codeserver-setup/extensions.sh
  ```
- After running `extensions.sh`, the user must reload the code-server browser tab (Cmd/Ctrl+Shift+P → "Developer: Reload Window") for new extensions to activate.
- **Critical gotcha for any future code-server CLI work:** invoking `/app/code-server/bin/code-server --install-extension ...` from inside the running container fails with `error not spawned with IPC` because environment variables from the parent code-server process (VSCODE_*, etc.) make the CLI try to talk over IPC. Fix: wrap in `env -i HOME=... PATH=... USER=... <cmd>`. The `code_server_cli` function in extensions.sh demonstrates this.
- **When proposing new tooling:** if it's a system package, add to `install.sh`. If it's a VS Code extension or editor setting, add to `extensions.sh`. Don't suggest installing via the running container's package manager directly — it won't survive a redeploy.

Related: [[evolution-workspace-mapping]] for the broader container/host architecture.
