Skip to content

Commit ea9eb9c

Browse files
committed
feat(devcontainer): add opencode server service
1 parent 0492b7d commit ea9eb9c

6 files changed

Lines changed: 64 additions & 14 deletions

File tree

.devcontainer/Dockerfile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@ ARG DOTFILES_GITHUB_USERNAME=kvokka
44
WORKDIR /home/vscode
55
USER vscode
66

7+
# https://mise.jdx.dev/troubleshooting.html#_403-forbidden-when-installing-a-tool
8+
ARG MISE_GITHUB_TOKEN
9+
ARG GITHUB_TOKEN
10+
ARG GITHUB_API_TOKEN
11+
712
RUN bash -c "$(curl -fsLS https://raw.githubusercontent.com/${DOTFILES_GITHUB_USERNAME}/dotfiles/refs/heads/master/bootstrap.sh)" \
813
-- ${DOTFILES_GITHUB_USERNAME}
914

.devcontainer/devcontainer.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@
1212
"features": {
1313
"ghcr.io/devcontainers/features/docker-outside-of-docker:1": {}
1414
},
15+
"runArgs": [
16+
"--env-file",
17+
"~/.devcontainer/.env.devcontainer"
18+
],
1519
// Configure tool-specific properties.
1620
"customizations": {
1721
// Configure properties specific to VS Code.

.devcontainer/entrypoint.sh

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,9 @@
1-
#!/bin/bash
1+
#!/usr/bin/env zsh
22

3-
# prepare data for https://github.com/ithena-one/mcp-safe-run
4-
if [ -f ~/.devcontainer/.env.devcontainer ]; then
5-
mkdir -p ~/.secrets
6-
while IFS='=' read -r key value; do
7-
[[ -n "$key" && ! "$key" =~ ^# ]] && echo "$value" > ~/.secrets/"$key"
8-
done < ~/.devcontainer/.env.devcontainer
9-
fi
10-
11-
DOCKER_GID=999
12-
groupadd -g ${DOCKER_GID} docker && \
13-
chown root:docker /var/run/docker.sock && \
14-
usermod -aG docker vscode
3+
source ~/.zsh/homebrew.zsh
4+
eval "$(mise activate zsh)"
155

166
ln -s -f ~/.devcontainer/shared /workspace/shared
17-
ln -s -f ~/.rovodev /workspace/.rovodev
187

198
if [ -f ~/.devcontainer/shared/opencode/antigravity-accounts.json ]; then
209
ln -s -f ~/.devcontainer/shared/opencode/antigravity-accounts.json ~/.config/opencode/antigravity-accounts.json

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -342,3 +342,4 @@ logs/*
342342
**/tmp
343343
shared
344344
.devcontainer/proxy/mitmproxy/
345+
.rumdl_cache/

README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,24 @@ different projects AND for MCP's use `~./.devcontainer/.env.devcontainer`.
8080
responses from other services (local MitM), [details](./.devcontainer/proxy/README.md)
8181
- There is a shared folder from outside of the project workspace `~/.devcontainer/shared` that is forwarded to `/workspace/shared` path. This path is ignored from git
8282

83+
### OpenCode Server
84+
85+
The devcontainer includes a pre-configured OpenCode server running on port 4096.
86+
87+
You can open it in the browser on the address <http://localhost:4096>
88+
89+
To connect to this existing session instead of starting a new one:
90+
91+
```bash
92+
opencode attach http://localhost:4096
93+
```
94+
95+
#### Auth
96+
97+
use `opencode auth login` to login to the Opencode providers, GCP auth info is
98+
shared across the providers, see `~/.devcontainer/shared/opencode/` on the host
99+
machine for more info
100+
83101
## References
84102

85103
The original boilerplate was from from this MS [repo](https://github.com/microsoft/vscode-remote-try-go)

docker-compose.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,27 @@
11
name: app-workspace
22

3+
networks:
4+
app-workspace-net:
5+
driver: bridge
6+
name: app-workspace-net-name
7+
attachable: true
8+
external: false
9+
310
services:
411
app:
512
env_file:
613
- path: ~/.devcontainer/.env.devcontainer
714
required: false
815
- path: .env
916
required: false
17+
image: app-workspace-image
1018
build:
1119
context: .
1220
dockerfile: .devcontainer/Dockerfile
21+
args:
22+
MISE_GITHUB_TOKEN: ${MISE_GITHUB_TOKEN}
23+
GITHUB_TOKEN: ${GITHUB_TOKEN}
24+
GITHUB_API_TOKEN: ${GITHUB_API_TOKEN}
1325
volumes:
1426
- .:/workspace:cached
1527
- ~/.devcontainer:/home/vscode/.devcontainer:cached
@@ -18,6 +30,8 @@ services:
1830
# - "3000:3000"
1931
user: vscode # connected with remoteUser in devcontainer.json
2032
working_dir: /workspace
33+
networks:
34+
- app-workspace-net
2135
# # Use this block for mitmproxy, #mitmproxy
2236
# environment:
2337
# - REQUESTS_CA_BUNDLE=/etc/ssl/certs/ca-certificates.crt
@@ -28,3 +42,22 @@ services:
2842
# - https_proxy=http://host.docker.internal:8888
2943
# extra_hosts:
3044
# - "host.docker.internal:host-gateway"
45+
opencode:
46+
image: app-workspace-image
47+
env_file:
48+
- path: ~/.devcontainer/.env.devcontainer
49+
required: false
50+
- path: .env
51+
required: false
52+
command: opencode serve --port 4096 --hostname 0.0.0.0
53+
ports:
54+
- "4096:4096"
55+
volumes:
56+
- .:/workspace:cached
57+
- ~/.devcontainer:/home/vscode/.devcontainer:cached
58+
working_dir: /workspace
59+
user: vscode
60+
networks:
61+
- app-workspace-net
62+
depends_on:
63+
- app

0 commit comments

Comments
 (0)