diff --git a/DOCKER_HUB.md b/DOCKER_HUB.md index a57841b..679ca6b 100644 --- a/DOCKER_HUB.md +++ b/DOCKER_HUB.md @@ -317,6 +317,28 @@ bun run src/index.ts Node modules are stored in your project directory under `/workspace` and persist automatically. +## VS Code Integration + +VS Code can connect directly to a running opencode-devbox container for a full IDE experience with IntelliSense, debugging, and extensions running inside the container. + +**Requirements:** Install the [Dev Containers](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers) extension. For remote Docker hosts, also install [Remote - SSH](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-ssh). + +**Steps:** + +1. Start the container: `docker compose up -d` +2. In VS Code: `Ctrl+Shift+P` → "Dev Containers: Attach to Running Container" → select `opencode-devbox` + +For remote Docker hosts (e.g. connecting to a server via SSH), first connect to the remote host with Remote-SSH, then attach to the container from there. + +VS Code extensions installed inside the container persist as long as the container exists. For persistent extension storage across container recreations, add a named volume: + +```bash +docker run -it --rm \ + -v devbox-vscode:/home/developer/.vscode-server \ + ... \ + joakimp/opencode-devbox:latest +``` + ## Using docker-compose Create a directory with a `docker-compose.yml` and a `.env` file: diff --git a/README.md b/README.md index 94be686..b8ff644 100644 --- a/README.md +++ b/README.md @@ -240,6 +240,30 @@ bun run src/index.ts Node modules are stored in your project directory under `/workspace` and persist automatically. +### VS Code integration + +VS Code can connect directly to a running opencode-devbox container for a full IDE experience with IntelliSense, debugging, and extensions running inside the container. + +**Local Docker (Docker running on your workstation):** + +1. Install the [Dev Containers](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers) extension +2. Start the container: `docker compose up -d` +3. In VS Code: `Ctrl+Shift+P` → "Dev Containers: Attach to Running Container" → select `opencode-devbox` + +**Remote Docker (Docker running on a remote server, e.g. via SSH):** + +1. Install the [Remote - SSH](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-ssh) and [Dev Containers](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers) extensions +2. Connect to the remote host: `Ctrl+Shift+P` → "Remote-SSH: Connect to Host" +3. On the remote host, start the container: `docker compose up -d` +4. In VS Code (now connected to the remote): `Ctrl+Shift+P` → "Dev Containers: Attach to Running Container" + +VS Code extensions installed inside the container persist as long as the container exists (not removed with `docker compose down`). For persistent extension storage across container recreations, add a named volume: + +```yaml +volumes: + - devbox-vscode:/home/developer/.vscode-server +``` + ### Rebuilding the Image `docker compose run` and `docker compose up` use the existing image — they **do not rebuild** when you change the Dockerfile or build args (e.g. updating `OPENCODE_VERSION`). Rebuild explicitly: