Compare commits
47 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| f08480182a | |||
| 5ec47fdf4b | |||
| 210cb7d1a1 | |||
| 0a3e142b8f | |||
| 158e1590a6 | |||
| 271dc2eb35 | |||
| 875afe0039 | |||
| 9e381ebe32 | |||
| 3e048218c3 | |||
| 6ecd65d18d | |||
| e58962a72c | |||
| d2c0447147 | |||
| 77a7daf67f | |||
| b3cfe641bb | |||
| f7bd21b9fe | |||
| 1b97d98155 | |||
| de659fbc54 | |||
| d651a084de | |||
| 18b4df23e5 | |||
| 60c83568cd | |||
| a8b5f23dba | |||
| a6972becd1 | |||
| a183ad7ac6 | |||
| 017f7f1343 | |||
| 56f98da914 | |||
| 078c095116 | |||
| e50617d9b9 | |||
| 986fed9e05 | |||
| 4729131e4e | |||
| 973e727acb | |||
| 9c8a2c0169 | |||
| 18e55aeb18 | |||
| 73e94c7e54 | |||
| fa4739e061 | |||
| b72079f9fa | |||
| ba41187e21 | |||
| 4112d30a3e | |||
| 8d06a737f1 | |||
| aaf7d66157 | |||
| bc1dceeaa1 | |||
| 7685facb37 | |||
| 94b64db751 | |||
| 9b1f7d1028 | |||
| 476d9fb4f5 | |||
| ca5efe1007 | |||
| 4b7b8a0c4b | |||
| c0b887791f |
+13
-1
@@ -10,7 +10,7 @@ OPENCODE_PROVIDER=anthropic
|
|||||||
# OPENCODE_MODEL=anthropic/claude-sonnet-4-5
|
# OPENCODE_MODEL=anthropic/claude-sonnet-4-5
|
||||||
|
|
||||||
# ── API Keys (set the one matching your provider) ────────────────────
|
# ── API Keys (set the one matching your provider) ────────────────────
|
||||||
ANTHROPIC_API_KEY=
|
# ANTHROPIC_API_KEY=
|
||||||
# OPENAI_API_KEY=
|
# OPENAI_API_KEY=
|
||||||
# GEMINI_API_KEY=
|
# GEMINI_API_KEY=
|
||||||
|
|
||||||
@@ -30,3 +30,15 @@ WORKSPACE_PATH=~/projects
|
|||||||
|
|
||||||
# Path to SSH keys on host
|
# Path to SSH keys on host
|
||||||
SSH_KEY_PATH=~/.ssh
|
SSH_KEY_PATH=~/.ssh
|
||||||
|
|
||||||
|
# ── Locale (defaults to en_US.UTF-8) ─────────────────────────────────
|
||||||
|
# LANG=sv_SE.UTF-8
|
||||||
|
# LANGUAGE=sv_SE:sv
|
||||||
|
# LC_ALL=sv_SE.UTF-8
|
||||||
|
|
||||||
|
# ── oh-my-opencode-slim (multi-agent orchestration) ──────────────────
|
||||||
|
# Requires image built with INSTALL_OMOS=true
|
||||||
|
# ENABLE_OMOS=false
|
||||||
|
# OMOS_TMUX=false # Enable tmux multiplexer integration
|
||||||
|
# OMOS_SKILLS=true # Install recommended skills (simplify, agent-browser, cartography)
|
||||||
|
# OMOS_RESET=false # Force regenerate oh-my-opencode-slim config on next start
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ on:
|
|||||||
- 'v*'
|
- 'v*'
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build-and-push:
|
build-base:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
container:
|
container:
|
||||||
image: catthehacker/ubuntu:act-latest
|
image: catthehacker/ubuntu:act-latest
|
||||||
@@ -14,11 +14,18 @@ jobs:
|
|||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Force IPv4 for Docker Hub
|
||||||
|
run: |
|
||||||
|
# Prefer IPv4 to avoid intermittent IPv6 connectivity failures
|
||||||
|
echo 'precedence ::ffff:0:0/96 100' >> /etc/gai.conf
|
||||||
|
|
||||||
- name: Set up QEMU
|
- name: Set up QEMU
|
||||||
uses: docker/setup-qemu-action@v4
|
uses: docker/setup-qemu-action@v4
|
||||||
|
|
||||||
- name: Set up Docker Buildx
|
- name: Set up Docker Buildx
|
||||||
uses: docker/setup-buildx-action@v4
|
uses: docker/setup-buildx-action@v4
|
||||||
|
with:
|
||||||
|
driver-opts: network=host
|
||||||
|
|
||||||
- name: Login to Docker Hub
|
- name: Login to Docker Hub
|
||||||
uses: docker/login-action@v4
|
uses: docker/login-action@v4
|
||||||
@@ -32,7 +39,7 @@ jobs:
|
|||||||
VERSION=${GITHUB_REF#refs/tags/}
|
VERSION=${GITHUB_REF#refs/tags/}
|
||||||
echo "version=${VERSION}" >> $GITHUB_OUTPUT
|
echo "version=${VERSION}" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
- name: Build and push
|
- name: Build and push (base)
|
||||||
uses: docker/build-push-action@v7
|
uses: docker/build-push-action@v7
|
||||||
with:
|
with:
|
||||||
context: .
|
context: .
|
||||||
@@ -41,3 +48,84 @@ jobs:
|
|||||||
tags: |
|
tags: |
|
||||||
${{ vars.DOCKERHUB_USERNAME }}/opencode-devbox:${{ steps.version.outputs.version }}
|
${{ vars.DOCKERHUB_USERNAME }}/opencode-devbox:${{ steps.version.outputs.version }}
|
||||||
${{ vars.DOCKERHUB_USERNAME }}/opencode-devbox:latest
|
${{ vars.DOCKERHUB_USERNAME }}/opencode-devbox:latest
|
||||||
|
|
||||||
|
build-omos:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
container:
|
||||||
|
image: catthehacker/ubuntu:act-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Force IPv4 for Docker Hub
|
||||||
|
run: |
|
||||||
|
# Prefer IPv4 to avoid intermittent IPv6 connectivity failures
|
||||||
|
echo 'precedence ::ffff:0:0/96 100' >> /etc/gai.conf
|
||||||
|
|
||||||
|
- name: Set up QEMU
|
||||||
|
uses: docker/setup-qemu-action@v4
|
||||||
|
|
||||||
|
- name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v4
|
||||||
|
with:
|
||||||
|
driver-opts: network=host
|
||||||
|
|
||||||
|
- name: Login to Docker Hub
|
||||||
|
uses: docker/login-action@v4
|
||||||
|
with:
|
||||||
|
username: ${{ vars.DOCKERHUB_USERNAME }}
|
||||||
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||||
|
|
||||||
|
- name: Extract version from tag
|
||||||
|
id: version
|
||||||
|
run: |
|
||||||
|
VERSION=${GITHUB_REF#refs/tags/}
|
||||||
|
echo "version=${VERSION}" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
|
- name: Build and push (omos)
|
||||||
|
uses: docker/build-push-action@v7
|
||||||
|
with:
|
||||||
|
context: .
|
||||||
|
platforms: linux/amd64,linux/arm64
|
||||||
|
push: true
|
||||||
|
build-args: |
|
||||||
|
INSTALL_OMOS=true
|
||||||
|
tags: |
|
||||||
|
${{ vars.DOCKERHUB_USERNAME }}/opencode-devbox:${{ steps.version.outputs.version }}-omos
|
||||||
|
${{ vars.DOCKERHUB_USERNAME }}/opencode-devbox:latest-omos
|
||||||
|
|
||||||
|
update-description:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
needs: [build-base, build-omos]
|
||||||
|
container:
|
||||||
|
image: catthehacker/ubuntu:act-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Update Docker Hub description
|
||||||
|
run: |
|
||||||
|
TOKEN=$(curl -s -X POST https://hub.docker.com/v2/auth/token \
|
||||||
|
-H "Content-Type: application/json" \
|
||||||
|
-d '{"identifier":"${{ vars.DOCKERHUB_USERNAME }}","secret":"${{ secrets.DOCKERHUB_TOKEN }}"}' \
|
||||||
|
| jq -r .access_token)
|
||||||
|
if [ "$TOKEN" = "null" ] || [ -z "$TOKEN" ]; then
|
||||||
|
echo "::error::Failed to authenticate with Docker Hub API"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
HTTP_CODE=$(jq -n \
|
||||||
|
--rawfile full DOCKER_HUB.md \
|
||||||
|
--arg short "Portable AI dev environment for opencode. Debian-based with git, Node.js, AWS CLI, and SSH support." \
|
||||||
|
'{"full_description": $full, "description": $short}' | \
|
||||||
|
curl -s -o /tmp/hub-response.txt -w "%{http_code}" -X PATCH \
|
||||||
|
"https://hub.docker.com/v2/repositories/${{ vars.DOCKERHUB_USERNAME }}/opencode-devbox/" \
|
||||||
|
-H "Authorization: Bearer $TOKEN" \
|
||||||
|
-H "Content-Type: application/json" \
|
||||||
|
-d @-)
|
||||||
|
echo "Docker Hub API returned: $HTTP_CODE"
|
||||||
|
if [ "$HTTP_CODE" != "200" ]; then
|
||||||
|
echo "Response body:"
|
||||||
|
cat /tmp/hub-response.txt
|
||||||
|
echo "::error::Docker Hub description update failed with HTTP $HTTP_CODE"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|||||||
@@ -0,0 +1,47 @@
|
|||||||
|
# AGENTS.md
|
||||||
|
|
||||||
|
## Project overview
|
||||||
|
|
||||||
|
Docker image packaging [opencode](https://opencode.ai) into a production-ready dev container. Two image variants (base and omos) are published to Docker Hub via Gitea Actions CI. Not a library or application — this is infrastructure (Dockerfile, entrypoint scripts, docker-compose, documentation).
|
||||||
|
|
||||||
|
## File roles
|
||||||
|
|
||||||
|
- `Dockerfile` — single multi-stage build for both variants. OMOS variant is controlled by `INSTALL_OMOS=true` build arg. All GitHub-sourced binaries are pinned with version ARGs.
|
||||||
|
- `entrypoint.sh` — runs as root: UID/GID adjustment, SSH permissions, volume ownership fixes. Then drops to developer via gosu.
|
||||||
|
- `entrypoint-user.sh` — runs as developer: git config, opencode.json generation from env vars, OMOS setup.
|
||||||
|
- `DOCKER_HUB.md` — pushed to Docker Hub description via CI API call. Must stay under 25KB. Short description field must be ≤100 bytes.
|
||||||
|
- `README.md` — source repo documentation. Must stay in sync with DOCKER_HUB.md (both describe the same features but for different audiences).
|
||||||
|
- `.gitea/workflows/docker-publish.yml` — CI pipeline: three parallel jobs (build-base, build-omos, update-description). Triggered by tag push only.
|
||||||
|
|
||||||
|
## Versioning scheme
|
||||||
|
|
||||||
|
Tags follow `v{opencode_version}{letter}` — e.g. `v1.4.3k`. The number matches the opencode npm version. The letter suffix increments for container-level changes (tooling, docs, CVE fixes) on the same opencode version. CI produces four Docker Hub tags per release: `vX.Y.Zn`, `latest`, `vX.Y.Zn-omos`, `latest-omos`.
|
||||||
|
|
||||||
|
## Critical conventions
|
||||||
|
|
||||||
|
- **entrypoint.sh volume ownership loop** — when adding a new named volume mount point, add it to the `for dir in ...` loop in `entrypoint.sh` so root-owned volumes get chowned on startup.
|
||||||
|
- **Three docs to keep in sync** — Dockerfile changes that add tools or features must be reflected in `README.md`, `DOCKER_HUB.md`, and `.env.example`. The docker-compose examples in both docs must match the source `docker-compose.yml` pattern.
|
||||||
|
- **GitHub-sourced binaries** — fzf, gosu, git-lfs, neovim, bat, eza, zoxide, uv, rustup are installed from upstream releases (not apt) with pinned versions. Use the same `ARCH` case-switch pattern for multi-arch support (amd64/arm64).
|
||||||
|
- **Shell scripts use `set -euo pipefail`** — both entrypoints are strict. Errors in volume chown or SSH permission operations are intentionally suppressed with `|| true`.
|
||||||
|
- **Docker Hub description update** — uses `/v2/auth/token` endpoint (not the deprecated `/v2/users/login`). Auth uses `identifier`/`secret` fields, returns `access_token`, sent as `Bearer`. Short description must be ≤100 bytes.
|
||||||
|
|
||||||
|
## CI quirks
|
||||||
|
|
||||||
|
- Both build jobs include an IPv4 preference step (`gai.conf` + `driver-opts: network=host` for buildx) to work around intermittent IPv6 failures on the Gitea runners.
|
||||||
|
- `update-description` job runs only when both builds succeed (`needs: [build-base, build-omos]`).
|
||||||
|
- Tags must be pushed to trigger CI. Pushing to `main` alone does not build images.
|
||||||
|
|
||||||
|
## Testing changes
|
||||||
|
|
||||||
|
No test suite. Verify by:
|
||||||
|
1. Building locally: `docker compose build`
|
||||||
|
2. Running: `docker compose run --rm devbox bash`
|
||||||
|
3. Checking tool availability inside container: `nvim --version`, `bat --version`, `uv --version`, etc.
|
||||||
|
4. For entrypoint changes: test with a non-1000 UID workspace to verify UID adjustment and volume ownership fixes.
|
||||||
|
|
||||||
|
## Commit style
|
||||||
|
|
||||||
|
Imperative mood, first line summarizes the change. Multi-line body explains "why" when non-obvious. Examples from history:
|
||||||
|
- `Fix ownership of named volume mount points in entrypoint`
|
||||||
|
- `Add uv package manager to base image for on-demand Python support`
|
||||||
|
- `Upgrade base image from Debian bookworm to trixie (current stable)`
|
||||||
+400
-31
@@ -2,6 +2,17 @@
|
|||||||
|
|
||||||
Portable AI developer environment for [opencode](https://opencode.ai). Debian-based, with git, SSH, Node.js, AWS CLI v2, and common dev tools pre-installed.
|
Portable AI developer environment for [opencode](https://opencode.ai). Debian-based, with git, SSH, Node.js, AWS CLI v2, and common dev tools pre-installed.
|
||||||
|
|
||||||
|
## Image Variants
|
||||||
|
|
||||||
|
Two image variants are published for each release:
|
||||||
|
|
||||||
|
| Tag | Description |
|
||||||
|
|---|---|
|
||||||
|
| `latest` / `vX.Y.Z` | Base image — opencode, Node.js, AWS CLI, dev tools |
|
||||||
|
| `latest-omos` / `vX.Y.Z-omos` | Base + [oh-my-opencode-slim](https://github.com/alvinunreal/oh-my-opencode-slim) multi-agent orchestration and Bun |
|
||||||
|
|
||||||
|
Both variants support `linux/amd64` and `linux/arm64`.
|
||||||
|
|
||||||
## Quick Start
|
## Quick Start
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
@@ -32,8 +43,35 @@ docker run -it --rm \
|
|||||||
|
|
||||||
Then run `opencode` when ready.
|
Then run `opencode` when ready.
|
||||||
|
|
||||||
|
## Running Multiple Shells
|
||||||
|
|
||||||
|
Once opencode is running it takes over the terminal. To have a separate shell for `aws`, `git`, or other commands, run the container in the background and attach multiple times:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Start in background
|
||||||
|
docker run -d --name devbox \
|
||||||
|
-e ANTHROPIC_API_KEY=your-key \
|
||||||
|
-e OPENCODE_PROVIDER=anthropic \
|
||||||
|
-v ~/projects:/workspace \
|
||||||
|
-v ~/.ssh:/home/developer/.ssh:ro \
|
||||||
|
joakimp/opencode-devbox:latest sleep infinity
|
||||||
|
|
||||||
|
# Shell 1: run opencode
|
||||||
|
docker exec -it -u developer devbox opencode
|
||||||
|
|
||||||
|
# Shell 2 (separate terminal): aws, git, etc.
|
||||||
|
docker exec -it -u developer devbox bash
|
||||||
|
|
||||||
|
# When done
|
||||||
|
docker rm -f devbox
|
||||||
|
```
|
||||||
|
|
||||||
|
> **Note:** Always use `-u developer` with `docker exec` — the container starts as root for UID adjustment, then drops to `developer`. Without `-u developer`, exec runs as root.
|
||||||
|
|
||||||
## Environment Variables
|
## Environment Variables
|
||||||
|
|
||||||
|
All configuration is done via environment variables, typically stored in a `.env` file.
|
||||||
|
|
||||||
### Provider Configuration
|
### Provider Configuration
|
||||||
|
|
||||||
| Variable | Description | Default |
|
| Variable | Description | Default |
|
||||||
@@ -56,14 +94,7 @@ Set the key matching your provider:
|
|||||||
| Variable | Description | Default |
|
| Variable | Description | Default |
|
||||||
|---|---|---|
|
|---|---|---|
|
||||||
| `AWS_REGION` | AWS region | `us-east-1` |
|
| `AWS_REGION` | AWS region | `us-east-1` |
|
||||||
| `AWS_PROFILE` | AWS profile name | `default` |
|
| `AWS_PROFILE` | AWS SSO profile name | `default` |
|
||||||
|
|
||||||
For SSO authentication, start with `bash` and run:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
aws sso login --sso-session <your-session> --use-device-code
|
|
||||||
opencode
|
|
||||||
```
|
|
||||||
|
|
||||||
### Git
|
### Git
|
||||||
|
|
||||||
@@ -72,79 +103,417 @@ opencode
|
|||||||
| `GIT_USER_NAME` | Git commit author name |
|
| `GIT_USER_NAME` | Git commit author name |
|
||||||
| `GIT_USER_EMAIL` | Git commit author email |
|
| `GIT_USER_EMAIL` | Git commit author email |
|
||||||
|
|
||||||
## Volumes
|
### User ID Mapping
|
||||||
|
|
||||||
| Host Path | Container Path | Purpose |
|
The container runs as user `developer` (UID 1000 by default). If your host user has a different UID, file permission mismatches can occur on mounted volumes.
|
||||||
|
|
||||||
|
The entrypoint automatically detects the owner of `/workspace` and adjusts the container user's UID/GID to match. You can also set it explicitly:
|
||||||
|
|
||||||
|
| Variable | Description | Default |
|
||||||
|---|---|---|
|
|---|---|---|
|
||||||
| Your project directory | `/workspace` | Code you want to work on |
|
| `USER_UID` | Container user UID | Auto-detect from `/workspace` owner |
|
||||||
| `~/.ssh` | `/home/developer/.ssh:ro` | SSH keys for git (read-only) |
|
| `USER_GID` | Container user GID | Auto-detect from `/workspace` owner |
|
||||||
| (optional) `~/.aws` | `/home/developer/.aws:ro` | AWS credentials/config |
|
|
||||||
| (optional) Custom config | `/home/developer/.config/opencode/opencode.json:ro` | Full opencode config with MCP servers, etc. |
|
|
||||||
|
|
||||||
### Persisting opencode data
|
### Locale and Editor
|
||||||
|
|
||||||
To keep opencode state (session history, memory) between runs, add a named volume:
|
The container defaults to English (`en_US.UTF-8`) and neovim as the editor. Override via environment variables:
|
||||||
|
|
||||||
|
| Variable | Description | Default |
|
||||||
|
|---|---|---|
|
||||||
|
| `LANG` | System locale | `en_US.UTF-8` |
|
||||||
|
| `LANGUAGE` | Language priority list | `en_US:en` |
|
||||||
|
| `LC_ALL` | Override all locale settings | `en_US.UTF-8` |
|
||||||
|
| `EDITOR` | Default text editor | `nvim` |
|
||||||
|
|
||||||
|
All common UTF-8 locales are pre-generated in the image. Example for Swedish:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
docker run -it --rm \
|
LANG=sv_SE.UTF-8
|
||||||
-v opencode-data:/home/developer/.local/share/opencode \
|
LANGUAGE=sv_SE:sv
|
||||||
... \
|
LC_ALL=sv_SE.UTF-8
|
||||||
joakimp/opencode-devbox:latest
|
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Initial Setup
|
||||||
|
|
||||||
|
### 1. Create host directories
|
||||||
|
|
||||||
|
Bind-mounted directories must exist on the host before starting the container. Docker creates missing directories as root-owned, which causes permission issues.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Required
|
||||||
|
mkdir -p ~/projects
|
||||||
|
|
||||||
|
# If mounting opencode config (recommended for persistent settings)
|
||||||
|
mkdir -p ~/.config/opencode
|
||||||
|
|
||||||
|
# If using AWS Bedrock
|
||||||
|
# mkdir -p ~/.aws
|
||||||
|
|
||||||
|
# If mounting neovim config
|
||||||
|
# mkdir -p ~/.config/nvim
|
||||||
|
```
|
||||||
|
|
||||||
|
### 2. Create a `.env` file
|
||||||
|
|
||||||
|
Create a `.env` file with your configuration. Examples for each provider:
|
||||||
|
|
||||||
|
**Anthropic:**
|
||||||
|
```bash
|
||||||
|
OPENCODE_PROVIDER=anthropic
|
||||||
|
ANTHROPIC_API_KEY=sk-ant-...
|
||||||
|
GIT_USER_NAME=Your Name
|
||||||
|
GIT_USER_EMAIL=you@example.com
|
||||||
|
```
|
||||||
|
|
||||||
|
**OpenAI:**
|
||||||
|
```bash
|
||||||
|
OPENCODE_PROVIDER=openai
|
||||||
|
OPENAI_API_KEY=sk-...
|
||||||
|
GIT_USER_NAME=Your Name
|
||||||
|
GIT_USER_EMAIL=you@example.com
|
||||||
|
```
|
||||||
|
|
||||||
|
**AWS Bedrock (SSO):**
|
||||||
|
```bash
|
||||||
|
OPENCODE_PROVIDER=amazon-bedrock
|
||||||
|
OPENCODE_MODEL=amazon-bedrock/eu.anthropic.claude-opus-4-6-v1
|
||||||
|
AWS_REGION=eu-west-1
|
||||||
|
AWS_PROFILE=your-profile-name
|
||||||
|
GIT_USER_NAME=Your Name
|
||||||
|
GIT_USER_EMAIL=you@example.com
|
||||||
|
```
|
||||||
|
|
||||||
|
### 3. AWS SSO setup (Bedrock users only)
|
||||||
|
|
||||||
|
AWS SSO requires a `~/.aws/config` file on the host with your SSO session configuration. If you already have this on another machine, copy it:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
scp -r user@other-machine:~/.aws ~/.aws
|
||||||
|
```
|
||||||
|
|
||||||
|
Or configure from scratch:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
aws configure sso
|
||||||
|
```
|
||||||
|
|
||||||
|
You'll be prompted for:
|
||||||
|
- SSO session name
|
||||||
|
- SSO start URL
|
||||||
|
- SSO region
|
||||||
|
- Registration scopes (typically `sso:account:access`)
|
||||||
|
|
||||||
|
The `~/.aws` directory must be mounted into the container (see docker-compose example below).
|
||||||
|
|
||||||
|
## Data Storage and Persistence
|
||||||
|
|
||||||
|
Understanding what survives container restarts and what doesn't:
|
||||||
|
|
||||||
|
| Path in container | Source | Survives restart? | Contains |
|
||||||
|
|---|---|---|---|
|
||||||
|
| `/workspace` | Host bind mount | ✅ Yes — lives on host | Your project files |
|
||||||
|
| `/home/developer/.ssh` | Host bind mount (ro) | ✅ Yes — lives on host | SSH keys |
|
||||||
|
| `/home/developer/.aws` | Host bind mount | ✅ Yes — lives on host | AWS credentials/SSO cache |
|
||||||
|
| `/home/developer/.local/share/opencode` | Named volume (if configured) | ✅ Yes — Docker volume | Session history, memory, auth tokens |
|
||||||
|
| `/home/developer/.local/share/uv` | Named volume (if configured) | ✅ Yes — Docker volume | Python installs, uv tool installs |
|
||||||
|
| `/home/developer/.rustup` | Named volume (if configured) | ✅ Yes — Docker volume | Rust toolchains |
|
||||||
|
| `/home/developer/.cargo` | Named volume (if configured) | ✅ Yes — Docker volume | Cargo binaries, registry cache |
|
||||||
|
| `/home/developer/.vscode-server` | Named volume (if configured) | ✅ Yes — Docker volume | VS Code server and extensions |
|
||||||
|
| `/home/developer/.config/opencode` | Host bind mount (if configured) | ✅ Yes — lives on host | opencode.json, oh-my-opencode-slim.json, skills |
|
||||||
|
|
||||||
|
### Key points
|
||||||
|
|
||||||
|
- **Project files** (`/workspace`) are always safe — they're your host filesystem.
|
||||||
|
- **opencode config** is auto-generated from `OPENCODE_PROVIDER` env var on each start if no existing config is found. To persist config changes, mount the config directory from the host (see Custom opencode Config below).
|
||||||
|
- **opencode data** (session history, memory) is lost with `--rm` unless you add a named volume.
|
||||||
|
- **Python installs** via `uv python install` are lost unless you add the `devbox-uv` named volume.
|
||||||
|
- **Rust toolchains** via `rustup-init` are lost unless you add the `devbox-rustup` and `devbox-cargo` named volumes.
|
||||||
|
- **AWS SSO tokens** persist across restarts when `~/.aws` is mounted (recommended for Bedrock users).
|
||||||
|
|
||||||
## Custom opencode Config
|
## Custom opencode Config
|
||||||
|
|
||||||
For full control (MCP servers, custom models, keybindings), mount your own config:
|
For full control over opencode settings (MCP servers, custom models, oh-my-opencode-slim agents, etc.), mount the entire config directory from the host:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
docker run -it --rm \
|
docker run -it --rm \
|
||||||
-v ./my-opencode.json:/home/developer/.config/opencode/opencode.json:ro \
|
-v ~/.config/opencode:/home/developer/.config/opencode \
|
||||||
... \
|
... \
|
||||||
joakimp/opencode-devbox:latest
|
joakimp/opencode-devbox:latest
|
||||||
```
|
```
|
||||||
|
|
||||||
When a config file is mounted, the `OPENCODE_PROVIDER` auto-config is skipped.
|
This persists all configuration changes across container restarts. When an existing `opencode.json` is found, the `OPENCODE_PROVIDER` auto-config is skipped.
|
||||||
|
|
||||||
|
## Neovim Configuration
|
||||||
|
|
||||||
|
The image includes neovim 0.12 with `EDITOR=nvim` set by default. To use your own neovim config (and have plugins auto-install via lazy.nvim on first start), mount it from the host:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
docker run -it --rm \
|
||||||
|
-v ~/.config/nvim:/home/developer/.config/nvim:ro \
|
||||||
|
... \
|
||||||
|
joakimp/opencode-devbox:latest
|
||||||
|
```
|
||||||
|
|
||||||
|
## Python Development with uv
|
||||||
|
|
||||||
|
The image includes Python 3.13 (from Debian Trixie) and [uv](https://docs.astral.sh/uv/), a fast Python package manager that replaces pip, venv, and pyenv:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Python 3.13 is available out of the box
|
||||||
|
python3 --version
|
||||||
|
|
||||||
|
# Use uv for package management
|
||||||
|
uv venv
|
||||||
|
uv pip install -r requirements.txt
|
||||||
|
|
||||||
|
# Or use uv's project workflow (reads pyproject.toml)
|
||||||
|
uv sync
|
||||||
|
|
||||||
|
# Run a Python script
|
||||||
|
uv run python script.py
|
||||||
|
|
||||||
|
# Install standalone Python tools
|
||||||
|
uvx ruff check .
|
||||||
|
|
||||||
|
# Install a newer Python version (persists with devbox-uv volume)
|
||||||
|
uv python install 3.14
|
||||||
|
```
|
||||||
|
|
||||||
|
To persist Python installs across container restarts, add a named volume:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
docker run -it --rm \
|
||||||
|
-v devbox-uv:/home/developer/.local/share/uv \
|
||||||
|
... \
|
||||||
|
joakimp/opencode-devbox:latest
|
||||||
|
```
|
||||||
|
|
||||||
|
Project virtual environments (`.venv`) are stored in your workspace directory and persist automatically via the `/workspace` bind mount.
|
||||||
|
|
||||||
|
## Rust Development with rustup
|
||||||
|
|
||||||
|
The image includes `rustup-init`, the Rust toolchain installer. Rust is not pre-installed but can be bootstrapped on demand:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# One-time setup: install Rust toolchain (~300MB, persists with volumes)
|
||||||
|
rustup-init -y
|
||||||
|
source ~/.cargo/env
|
||||||
|
|
||||||
|
# Now use Rust normally
|
||||||
|
cargo new my-project
|
||||||
|
cargo build
|
||||||
|
cargo run
|
||||||
|
```
|
||||||
|
|
||||||
|
To persist Rust toolchains and cargo data across container restarts, add named volumes:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
docker run -it --rm \
|
||||||
|
-v devbox-rustup:/home/developer/.rustup \
|
||||||
|
-v devbox-cargo:/home/developer/.cargo \
|
||||||
|
... \
|
||||||
|
joakimp/opencode-devbox:latest
|
||||||
|
```
|
||||||
|
|
||||||
|
## JavaScript and TypeScript
|
||||||
|
|
||||||
|
The base image includes **Node.js 22** and **npm** — sufficient for most JavaScript and TypeScript development:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Initialize a new project
|
||||||
|
npm init -y
|
||||||
|
|
||||||
|
# Install dependencies
|
||||||
|
npm install
|
||||||
|
|
||||||
|
# Run TypeScript (via tsx, ts-node, etc.)
|
||||||
|
npx tsx src/index.ts
|
||||||
|
```
|
||||||
|
|
||||||
|
The OMOS image variant also includes **Bun**, a faster JavaScript runtime and package manager:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
bun init
|
||||||
|
bun install
|
||||||
|
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
|
## Using docker-compose
|
||||||
|
|
||||||
Create a `docker-compose.yml`:
|
Create a directory with a `docker-compose.yml` and a `.env` file:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
mkdir opencode-devbox && cd opencode-devbox
|
||||||
|
```
|
||||||
|
|
||||||
|
`.env` — your settings (never commit this):
|
||||||
|
|
||||||
|
```bash
|
||||||
|
OPENCODE_PROVIDER=amazon-bedrock
|
||||||
|
OPENCODE_MODEL=amazon-bedrock/eu.anthropic.claude-opus-4-6-v1
|
||||||
|
AWS_REGION=eu-west-1
|
||||||
|
AWS_PROFILE=your-profile-name
|
||||||
|
GIT_USER_NAME=Your Name
|
||||||
|
GIT_USER_EMAIL=you@example.com
|
||||||
|
```
|
||||||
|
|
||||||
|
`docker-compose.yml`:
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
services:
|
services:
|
||||||
devbox:
|
devbox:
|
||||||
image: joakimp/opencode-devbox:latest
|
image: joakimp/opencode-devbox:latest
|
||||||
|
# For multi-agent orchestration, use the omos variant instead:
|
||||||
|
# image: joakimp/opencode-devbox:latest-omos
|
||||||
stdin_open: true
|
stdin_open: true
|
||||||
tty: true
|
tty: true
|
||||||
|
env_file:
|
||||||
|
- .env
|
||||||
environment:
|
environment:
|
||||||
- TERM=xterm-256color
|
- TERM=xterm-256color
|
||||||
- OPENCODE_PROVIDER=anthropic
|
|
||||||
- ANTHROPIC_API_KEY=${ANTHROPIC_API_KEY}
|
|
||||||
- GIT_USER_NAME=${GIT_USER_NAME}
|
|
||||||
- GIT_USER_EMAIL=${GIT_USER_EMAIL}
|
|
||||||
volumes:
|
volumes:
|
||||||
- ~/projects:/workspace
|
- ~/projects:/workspace
|
||||||
- ~/.ssh:/home/developer/.ssh:ro
|
- ~/.ssh:/home/developer/.ssh:ro
|
||||||
- devbox-data:/home/developer/.local/share/opencode
|
- devbox-data:/home/developer/.local/share/opencode
|
||||||
|
# Optional: persist Python/uv installs across restarts
|
||||||
|
# - devbox-uv:/home/developer/.local/share/uv
|
||||||
|
# Optional: persist Rust toolchains and cargo data
|
||||||
|
# - devbox-rustup:/home/developer/.rustup
|
||||||
|
# - devbox-cargo:/home/developer/.cargo
|
||||||
|
# Optional: persist VS Code server and extensions
|
||||||
|
# - devbox-vscode:/home/developer/.vscode-server
|
||||||
|
# Mount AWS config for Bedrock SSO (required for amazon-bedrock provider)
|
||||||
|
# - ~/.aws:/home/developer/.aws
|
||||||
|
# Optional: mount opencode config directory (persists config changes across restarts)
|
||||||
|
# - ~/.config/opencode:/home/developer/.config/opencode
|
||||||
|
# Optional: mount opencode agent skills from host
|
||||||
|
# - ~/.agents/skills:/home/developer/.agents/skills:ro
|
||||||
|
# Optional: mount neovim config from host (plugins auto-install on first start)
|
||||||
|
# - ~/.config/nvim:/home/developer/.config/nvim:ro
|
||||||
|
|
||||||
volumes:
|
volumes:
|
||||||
devbox-data:
|
devbox-data:
|
||||||
|
# devbox-uv:
|
||||||
|
# devbox-rustup:
|
||||||
|
# devbox-cargo:
|
||||||
|
# devbox-vscode:
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Docker Compose loads `.env` automatically from the same directory. All variables from `.env` are passed to the container via `env_file`. Do **not** hardcode provider settings in the `environment:` section — use `.env` instead.
|
||||||
|
|
||||||
Then:
|
Then:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
|
# Start in background
|
||||||
|
docker compose up -d
|
||||||
|
|
||||||
|
# Open a shell (always use -u developer with exec)
|
||||||
|
docker compose exec -u developer devbox bash
|
||||||
|
|
||||||
|
# For Bedrock: authenticate, then start opencode
|
||||||
|
aws sso login --sso-session <your-session> --use-device-code
|
||||||
|
opencode
|
||||||
|
|
||||||
|
# Or run opencode directly (if no SSO needed)
|
||||||
|
docker compose exec -u developer devbox opencode
|
||||||
|
|
||||||
|
# One-shot mode (creates and removes container)
|
||||||
docker compose run --rm devbox # direct to opencode
|
docker compose run --rm devbox # direct to opencode
|
||||||
docker compose run --rm devbox bash # interactive shell
|
docker compose run --rm devbox bash # interactive shell
|
||||||
```
|
```
|
||||||
|
|
||||||
## What's Included
|
## What's Included
|
||||||
|
|
||||||
- **Debian bookworm-slim** — glibc, full terminal/PTY support
|
### Base image (`latest`)
|
||||||
|
|
||||||
|
- **Debian trixie-slim** — glibc, full terminal/PTY support
|
||||||
- **opencode** — AI coding assistant
|
- **opencode** — AI coding assistant
|
||||||
- **Node.js 22** — for npx-based MCP servers
|
- **Node.js 22** — for npx-based MCP servers
|
||||||
- **AWS CLI v2** — SSO and Bedrock authentication
|
- **AWS CLI v2** — SSO and Bedrock authentication
|
||||||
- **Dev tools** — git, git-lfs, ssh, ripgrep, fd, fzf, jq, curl, wget, vim, tree
|
- **Dev tools** — git, git-lfs, ssh, ripgrep, fd, fzf, bat, eza, zoxide, uv, rustup, jq, make, curl, wget, neovim 0.12, tmux, htop, tree
|
||||||
- **Non-root user** — runs as `developer` (UID 1000) with sudo access
|
- **Non-root user** — runs as `developer` with UID auto-matched to workspace owner (sudo available)
|
||||||
|
|
||||||
|
### OMOS image (`latest-omos`)
|
||||||
|
|
||||||
|
Everything in the base image, plus:
|
||||||
|
|
||||||
|
- **[oh-my-opencode-slim](https://github.com/alvinunreal/oh-my-opencode-slim)** — multi-agent orchestration plugin
|
||||||
|
- **Bun** — JavaScript runtime required by oh-my-opencode-slim
|
||||||
|
- **6 specialized agents** — Orchestrator, Explorer, Oracle, Librarian, Designer, Fixer
|
||||||
|
|
||||||
|
### Additional runtimes (build from source)
|
||||||
|
|
||||||
|
When [building from source](https://gitea.jordbo.se/joakimp/opencode-devbox), additional runtimes are available via build args:
|
||||||
|
|
||||||
|
- **Python 3** (`INSTALL_PYTHON=true`) — Python 3 + pip + venv
|
||||||
|
- **Go** (`INSTALL_GO=true`) — Go toolchain
|
||||||
|
|
||||||
|
## oh-my-opencode-slim (OMOS variant)
|
||||||
|
|
||||||
|
The `-omos` image variant includes [oh-my-opencode-slim](https://github.com/alvinunreal/oh-my-opencode-slim), which adds a multi-agent layer on top of opencode. An Orchestrator delegates tasks to specialized agents, each configurable with different models and providers.
|
||||||
|
|
||||||
|
### Quick start with OMOS
|
||||||
|
|
||||||
|
```bash
|
||||||
|
docker run -it --rm \
|
||||||
|
-e OPENAI_API_KEY=your-key \
|
||||||
|
-e OPENCODE_PROVIDER=openai \
|
||||||
|
-e ENABLE_OMOS=true \
|
||||||
|
-v ~/projects:/workspace \
|
||||||
|
-v ~/.ssh:/home/developer/.ssh:ro \
|
||||||
|
joakimp/opencode-devbox:latest-omos
|
||||||
|
```
|
||||||
|
|
||||||
|
On first start, the entrypoint configures oh-my-opencode-slim automatically. The default preset uses OpenAI models.
|
||||||
|
|
||||||
|
### OMOS environment variables
|
||||||
|
|
||||||
|
| Variable | Default | Description |
|
||||||
|
|---|---|---|
|
||||||
|
| `ENABLE_OMOS` | `false` | Activate oh-my-opencode-slim on container start |
|
||||||
|
| `OMOS_TMUX` | `false` | Enable tmux pane integration (watch agents in split panes) |
|
||||||
|
| `OMOS_SKILLS` | `true` | Install recommended skills (simplify, agent-browser, cartography) |
|
||||||
|
| `OMOS_RESET` | `false` | Force regenerate config on next start (backs up existing config) |
|
||||||
|
|
||||||
|
### Custom OMOS configuration
|
||||||
|
|
||||||
|
If you mount the opencode config directory (see Custom opencode Config above), the `oh-my-opencode-slim.json` file is included and persists across restarts. Edit it directly to control which models power each agent, fallback chains, council setup, and more.
|
||||||
|
|
||||||
|
See the [oh-my-opencode-slim configuration docs](https://github.com/alvinunreal/oh-my-opencode-slim/blob/master/docs/configuration.md) for the full reference.
|
||||||
|
|
||||||
|
### Verifying agents
|
||||||
|
|
||||||
|
After starting opencode with OMOS enabled, run inside the opencode session:
|
||||||
|
|
||||||
|
```
|
||||||
|
ping all agents
|
||||||
|
```
|
||||||
|
|
||||||
|
All six agents should respond if your provider authentication is working.
|
||||||
|
|
||||||
## Source
|
## Source
|
||||||
|
|
||||||
|
|||||||
+95
-10
@@ -1,11 +1,11 @@
|
|||||||
# opencode-devbox — portable AI dev environment
|
# opencode-devbox — portable AI dev environment
|
||||||
# Debian-based container with opencode and configurable dev tools
|
# Debian-based container with opencode and configurable dev tools
|
||||||
|
|
||||||
ARG DEBIAN_VERSION=bookworm-slim
|
ARG DEBIAN_VERSION=trixie-slim
|
||||||
FROM debian:${DEBIAN_VERSION} AS base
|
FROM debian:${DEBIAN_VERSION} AS base
|
||||||
|
|
||||||
ARG TARGETARCH
|
ARG TARGETARCH
|
||||||
ARG OPENCODE_VERSION=1.4.2
|
ARG OPENCODE_VERSION=1.4.6
|
||||||
|
|
||||||
LABEL maintainer="joakimp"
|
LABEL maintainer="joakimp"
|
||||||
LABEL description="Portable opencode developer container"
|
LABEL description="Portable opencode developer container"
|
||||||
@@ -20,16 +20,18 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
|
|||||||
curl \
|
curl \
|
||||||
wget \
|
wget \
|
||||||
git \
|
git \
|
||||||
git-lfs \
|
|
||||||
openssh-client \
|
openssh-client \
|
||||||
gnupg \
|
gnupg \
|
||||||
jq \
|
jq \
|
||||||
ripgrep \
|
ripgrep \
|
||||||
fd-find \
|
fd-find \
|
||||||
fzf \
|
|
||||||
tree \
|
tree \
|
||||||
less \
|
less \
|
||||||
vim-tiny \
|
htop \
|
||||||
|
tmux \
|
||||||
|
make \
|
||||||
|
patch \
|
||||||
|
diffutils \
|
||||||
sudo \
|
sudo \
|
||||||
locales \
|
locales \
|
||||||
procps \
|
procps \
|
||||||
@@ -37,11 +39,81 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
|
|||||||
&& ln -s /usr/bin/fdfind /usr/local/bin/fd \
|
&& ln -s /usr/bin/fdfind /usr/local/bin/fd \
|
||||||
&& rm -rf /var/lib/apt/lists/*
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
# Set locale
|
# ── Go-compiled tools (install from GitHub to avoid CVEs in Debian's old Go builds)
|
||||||
RUN sed -i '/en_US.UTF-8/s/^# //g' /etc/locale.gen && locale-gen
|
|
||||||
|
# gosu — privilege de-escalation (built with Go 1.24.6)
|
||||||
|
ARG GOSU_VERSION=1.19
|
||||||
|
RUN ARCH=$(case "${TARGETARCH}" in amd64) echo "amd64" ;; arm64) echo "arm64" ;; *) echo "amd64" ;; esac) && \
|
||||||
|
curl -fsSL "https://github.com/tianon/gosu/releases/download/${GOSU_VERSION}/gosu-${ARCH}" -o /usr/local/bin/gosu && \
|
||||||
|
chmod +x /usr/local/bin/gosu && \
|
||||||
|
gosu --version
|
||||||
|
|
||||||
|
# fzf — fuzzy finder (built with Go 1.23.12)
|
||||||
|
ARG FZF_VERSION=0.71.0
|
||||||
|
RUN ARCH=$(case "${TARGETARCH}" in amd64) echo "amd64" ;; arm64) echo "arm64" ;; *) echo "amd64" ;; esac) && \
|
||||||
|
curl -fsSL "https://github.com/junegunn/fzf/releases/download/v${FZF_VERSION}/fzf-${FZF_VERSION}-linux_${ARCH}.tar.gz" | tar -xz -C /usr/local/bin fzf && \
|
||||||
|
fzf --version
|
||||||
|
|
||||||
|
# git-lfs — Git Large File Storage (built with Go 1.25)
|
||||||
|
ARG GIT_LFS_VERSION=3.7.1
|
||||||
|
RUN ARCH=$(case "${TARGETARCH}" in amd64) echo "amd64" ;; arm64) echo "arm64" ;; *) echo "amd64" ;; esac) && \
|
||||||
|
curl -fsSL "https://github.com/git-lfs/git-lfs/releases/download/v${GIT_LFS_VERSION}/git-lfs-linux-${ARCH}-v${GIT_LFS_VERSION}.tar.gz" | tar -xz -C /tmp && \
|
||||||
|
install /tmp/git-lfs-${GIT_LFS_VERSION}/git-lfs /usr/local/bin/git-lfs && \
|
||||||
|
rm -rf /tmp/git-lfs-${GIT_LFS_VERSION} && \
|
||||||
|
git lfs install --system && \
|
||||||
|
git-lfs --version
|
||||||
|
|
||||||
|
# neovim — modern text editor (pre-built release from GitHub)
|
||||||
|
ARG NVIM_VERSION=0.12.1
|
||||||
|
RUN ARCH=$(case "${TARGETARCH}" in amd64) echo "x86_64" ;; arm64) echo "arm64" ;; *) echo "x86_64" ;; esac) && \
|
||||||
|
curl -fsSL "https://github.com/neovim/neovim/releases/download/v${NVIM_VERSION}/nvim-linux-${ARCH}.tar.gz" | tar -xz -C /opt && \
|
||||||
|
ln -s /opt/nvim-linux-${ARCH}/bin/nvim /usr/local/bin/nvim && \
|
||||||
|
nvim --version | head -1
|
||||||
|
|
||||||
|
# bat — syntax-highlighted cat replacement
|
||||||
|
ARG BAT_VERSION=0.25.0
|
||||||
|
RUN ARCH=$(case "${TARGETARCH}" in amd64) echo "x86_64" ;; arm64) echo "aarch64" ;; *) echo "x86_64" ;; esac) && \
|
||||||
|
curl -fsSL "https://github.com/sharkdp/bat/releases/download/v${BAT_VERSION}/bat-v${BAT_VERSION}-${ARCH}-unknown-linux-musl.tar.gz" | tar -xz -C /tmp && \
|
||||||
|
install /tmp/bat-v${BAT_VERSION}-${ARCH}-unknown-linux-musl/bat /usr/local/bin/bat && \
|
||||||
|
rm -rf /tmp/bat-v${BAT_VERSION}-* && \
|
||||||
|
bat --version
|
||||||
|
|
||||||
|
# eza — modern ls replacement
|
||||||
|
ARG EZA_VERSION=0.23.4
|
||||||
|
RUN ARCH=$(case "${TARGETARCH}" in amd64) echo "x86_64" ;; arm64) echo "aarch64" ;; *) echo "x86_64" ;; esac) && \
|
||||||
|
curl -fsSL "https://github.com/eza-community/eza/releases/download/v${EZA_VERSION}/eza_${ARCH}-unknown-linux-gnu.tar.gz" | tar -xz -C /usr/local/bin && \
|
||||||
|
eza --version | head -1
|
||||||
|
|
||||||
|
# zoxide — smarter cd command
|
||||||
|
ARG ZOXIDE_VERSION=0.9.9
|
||||||
|
RUN ARCH=$(case "${TARGETARCH}" in amd64) echo "x86_64" ;; arm64) echo "aarch64" ;; *) echo "x86_64" ;; esac) && \
|
||||||
|
curl -fsSL "https://github.com/ajeetdsouza/zoxide/releases/download/v${ZOXIDE_VERSION}/zoxide-${ZOXIDE_VERSION}-${ARCH}-unknown-linux-musl.tar.gz" | tar -xz -C /usr/local/bin zoxide && \
|
||||||
|
zoxide --version
|
||||||
|
|
||||||
|
# uv — fast Python package manager (replaces pip, venv, pyenv)
|
||||||
|
ARG UV_VERSION=0.11.6
|
||||||
|
RUN ARCH=$(case "${TARGETARCH}" in amd64) echo "x86_64" ;; arm64) echo "aarch64" ;; *) echo "x86_64" ;; esac) && \
|
||||||
|
curl -fsSL "https://github.com/astral-sh/uv/releases/download/${UV_VERSION}/uv-${ARCH}-unknown-linux-musl.tar.gz" | tar -xz -C /tmp && \
|
||||||
|
install /tmp/uv-${ARCH}-unknown-linux-musl/uv /usr/local/bin/uv && \
|
||||||
|
install /tmp/uv-${ARCH}-unknown-linux-musl/uvx /usr/local/bin/uvx && \
|
||||||
|
rm -rf /tmp/uv-* && \
|
||||||
|
uv --version
|
||||||
|
|
||||||
|
# rustup — Rust toolchain manager
|
||||||
|
# Installs the rustup-init binary only. Users bootstrap Rust with:
|
||||||
|
# rustup-init -y && source ~/.cargo/env
|
||||||
|
# Toolchains persist via devbox-rustup and devbox-cargo volumes.
|
||||||
|
RUN ARCH=$(case "${TARGETARCH}" in amd64) echo "x86_64" ;; arm64) echo "aarch64" ;; *) echo "x86_64" ;; esac) && \
|
||||||
|
curl -fsSL "https://static.rust-lang.org/rustup/dist/${ARCH}-unknown-linux-gnu/rustup-init" -o /usr/local/bin/rustup-init && \
|
||||||
|
chmod +x /usr/local/bin/rustup-init
|
||||||
|
|
||||||
|
# Set locale — generate common UTF-8 locales (override via LANG/LC_ALL env vars)
|
||||||
|
RUN sed -i '/\.UTF-8/s/^# //g' /etc/locale.gen && locale-gen
|
||||||
ENV LANG=en_US.UTF-8
|
ENV LANG=en_US.UTF-8
|
||||||
ENV LANGUAGE=en_US:en
|
ENV LANGUAGE=en_US:en
|
||||||
ENV LC_ALL=en_US.UTF-8
|
ENV LC_ALL=en_US.UTF-8
|
||||||
|
ENV EDITOR=nvim
|
||||||
|
ENV PATH="/home/developer/.local/bin:/home/developer/.cargo/bin:${PATH}"
|
||||||
|
|
||||||
# ── Node.js (required for opencode v1.x install + MCP servers) ──────
|
# ── Node.js (required for opencode v1.x install + MCP servers) ──────
|
||||||
ARG NODE_VERSION=22
|
ARG NODE_VERSION=22
|
||||||
@@ -84,6 +156,17 @@ RUN if [ "${INSTALL_GO}" = "true" ]; then \
|
|||||||
ln -s /usr/local/go/bin/gofmt /usr/local/bin/gofmt; \
|
ln -s /usr/local/go/bin/gofmt /usr/local/bin/gofmt; \
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# ── Optional: oh-my-opencode-slim (multi-agent orchestration) ────────
|
||||||
|
# Installs Bun runtime and the oh-my-opencode-slim npm package.
|
||||||
|
# Runtime activation is controlled by ENABLE_OMOS env var in entrypoint.
|
||||||
|
ARG INSTALL_OMOS=false
|
||||||
|
ARG OMOS_VERSION=latest
|
||||||
|
RUN if [ "${INSTALL_OMOS}" = "true" ]; then \
|
||||||
|
curl -fsSL https://bun.sh/install | BUN_INSTALL=/usr/local bash && \
|
||||||
|
bun --version && \
|
||||||
|
npm install -g oh-my-opencode-slim@${OMOS_VERSION}; \
|
||||||
|
fi
|
||||||
|
|
||||||
# ── Non-root user ────────────────────────────────────────────────────
|
# ── Non-root user ────────────────────────────────────────────────────
|
||||||
ARG USER_NAME=developer
|
ARG USER_NAME=developer
|
||||||
ARG USER_UID=1000
|
ARG USER_UID=1000
|
||||||
@@ -95,16 +178,18 @@ RUN groupadd --gid ${USER_GID} ${USER_NAME} && \
|
|||||||
|
|
||||||
# Create standard directories
|
# Create standard directories
|
||||||
RUN mkdir -p /workspace \
|
RUN mkdir -p /workspace \
|
||||||
/home/${USER_NAME}/.config/opencode \
|
/home/${USER_NAME}/.config/opencode/skills \
|
||||||
|
/home/${USER_NAME}/.agents/skills \
|
||||||
/home/${USER_NAME}/.local/share/opencode \
|
/home/${USER_NAME}/.local/share/opencode \
|
||||||
/home/${USER_NAME}/.ssh && \
|
/home/${USER_NAME}/.ssh && \
|
||||||
chown -R ${USER_NAME}:${USER_NAME} /workspace /home/${USER_NAME}
|
chown -R ${USER_NAME}:${USER_NAME} /workspace /home/${USER_NAME}
|
||||||
|
|
||||||
# ── Entrypoint ────────────────────────────────────────────────────────
|
# ── Entrypoint ────────────────────────────────────────────────────────
|
||||||
COPY entrypoint.sh /usr/local/bin/entrypoint.sh
|
COPY entrypoint.sh /usr/local/bin/entrypoint.sh
|
||||||
RUN chmod +x /usr/local/bin/entrypoint.sh
|
COPY entrypoint-user.sh /usr/local/bin/entrypoint-user.sh
|
||||||
|
RUN chmod +x /usr/local/bin/entrypoint.sh /usr/local/bin/entrypoint-user.sh
|
||||||
|
|
||||||
USER ${USER_NAME}
|
# Start as root — entrypoint adjusts UID/GID then drops to developer
|
||||||
WORKDIR /workspace
|
WORKDIR /workspace
|
||||||
|
|
||||||
ENTRYPOINT ["entrypoint.sh"]
|
ENTRYPOINT ["entrypoint.sh"]
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ cp .env.example .env
|
|||||||
# Edit .env with your provider, API key, workspace path, git config
|
# Edit .env with your provider, API key, workspace path, git config
|
||||||
|
|
||||||
# Install git hooks (secret scanning)
|
# Install git hooks (secret scanning)
|
||||||
brew install gitleaks # one-time
|
brew install gitleaks # macOS / Linuxbrew
|
||||||
./setup-hooks.sh
|
./setup-hooks.sh
|
||||||
|
|
||||||
# Build and run
|
# Build and run
|
||||||
@@ -27,18 +27,33 @@ docker compose run --rm devbox
|
|||||||
|
|
||||||
## Features
|
## Features
|
||||||
|
|
||||||
- **Debian bookworm** base — glibc, full PTY/terminal support
|
- **Debian trixie** base — glibc, full PTY/terminal support
|
||||||
- **Configurable providers** — Anthropic, OpenAI, AWS Bedrock via env vars
|
- **Configurable providers** — Anthropic, OpenAI, AWS Bedrock via env vars
|
||||||
- **Host filesystem access** — bind mount any directory as `/workspace`
|
- **Host filesystem access** — bind mount any directory as `/workspace`
|
||||||
- **SSH key forwarding** — git push/pull to private repos
|
- **SSH key forwarding** — git push/pull to private repos
|
||||||
- **MCP server support** — Node.js included for `npx`-based MCP servers
|
- **MCP server support** — Node.js included for `npx`-based MCP servers
|
||||||
- **Non-root user** — runs as `developer` (UID 1000) with sudo
|
- **Non-root user** — runs as `developer` with UID auto-matched to workspace owner (sudo available)
|
||||||
- **Optional runtimes** — Python, Go via build args (Node.js always included — required for opencode v1.x)
|
- **Python via uv** — `uv` package manager included; install Python on demand with `uv python install`
|
||||||
|
- **Rust via rustup** — `rustup-init` included; bootstrap Rust on demand with `rustup-init -y`
|
||||||
|
- **Optional runtimes** — Python (apt), Go via build args (Node.js always included — required for opencode v1.x)
|
||||||
|
- **Multi-agent orchestration** — optional [oh-my-opencode-slim](https://github.com/alvinunreal/oh-my-opencode-slim) integration via build arg
|
||||||
- **AWS CLI v2** — built-in SSO/Bedrock authentication with headless device-code flow
|
- **AWS CLI v2** — built-in SSO/Bedrock authentication with headless device-code flow
|
||||||
- **Multi-arch** — amd64 and arm64
|
- **Multi-arch** — amd64 and arm64
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
|
### Prerequisites
|
||||||
|
|
||||||
|
Bind-mounted directories must exist on the host before starting the container. Docker creates missing directories as root-owned, which causes permission issues.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Required: workspace for your projects
|
||||||
|
mkdir -p ~/projects
|
||||||
|
|
||||||
|
# If mounting opencode config (recommended for persistent settings)
|
||||||
|
mkdir -p ~/.config/opencode
|
||||||
|
```
|
||||||
|
|
||||||
### Connecting to the container
|
### Connecting to the container
|
||||||
|
|
||||||
From your laptop, SSH into the remote server where Docker is running, then start the container:
|
From your laptop, SSH into the remote server where Docker is running, then start the container:
|
||||||
@@ -76,10 +91,10 @@ docker compose run --rm devbox
|
|||||||
docker compose up -d
|
docker compose up -d
|
||||||
|
|
||||||
# Attach a shell to the running container
|
# Attach a shell to the running container
|
||||||
docker compose exec devbox bash
|
docker compose exec -u developer devbox bash
|
||||||
|
|
||||||
# Or run a single command inside it
|
# Or run a single command inside it
|
||||||
docker compose exec devbox aws --version
|
docker compose exec -u developer devbox aws --version
|
||||||
```
|
```
|
||||||
|
|
||||||
> `run` creates a new container (cleaned up with `--rm`). `exec` attaches to an already running one.
|
> `run` creates a new container (cleaned up with `--rm`). `exec` attaches to an already running one.
|
||||||
@@ -95,18 +110,165 @@ docker compose exec devbox aws --version
|
|||||||
| `ANTHROPIC_API_KEY` | Anthropic API key | — |
|
| `ANTHROPIC_API_KEY` | Anthropic API key | — |
|
||||||
| `OPENAI_API_KEY` | OpenAI API key | — |
|
| `OPENAI_API_KEY` | OpenAI API key | — |
|
||||||
| `AWS_REGION` | AWS region for Bedrock | `us-east-1` |
|
| `AWS_REGION` | AWS region for Bedrock | `us-east-1` |
|
||||||
|
| `AWS_PROFILE` | AWS SSO profile name | `default` |
|
||||||
| `GIT_USER_NAME` | Git commit author name | — |
|
| `GIT_USER_NAME` | Git commit author name | — |
|
||||||
| `GIT_USER_EMAIL` | Git commit author email | — |
|
| `GIT_USER_EMAIL` | Git commit author email | — |
|
||||||
| `WORKSPACE_PATH` | Host path to mount | `.` |
|
| `WORKSPACE_PATH` | Host path to mount | `.` |
|
||||||
| `SSH_KEY_PATH` | Host SSH key directory | `~/.ssh` |
|
| `SSH_KEY_PATH` | Host SSH key directory | `~/.ssh` |
|
||||||
|
| `USER_UID` | Override container user UID | Auto-detect from `/workspace` |
|
||||||
|
| `USER_GID` | Override container user GID | Auto-detect from `/workspace` |
|
||||||
|
| `LANG` | System locale | `en_US.UTF-8` |
|
||||||
|
| `LANGUAGE` | Language priority list | `en_US:en` |
|
||||||
|
| `LC_ALL` | Override all locale settings | `en_US.UTF-8` |
|
||||||
|
| `EDITOR` | Default text editor | `nvim` |
|
||||||
|
| `ENABLE_OMOS` | Enable oh-my-opencode-slim multi-agent orchestration | `false` |
|
||||||
|
| `OMOS_TMUX` | Enable tmux pane integration for OMOS | `false` |
|
||||||
|
| `OMOS_SKILLS` | Install OMOS recommended skills on first run | `true` |
|
||||||
|
| `OMOS_RESET` | Force regenerate OMOS config on next start | `false` |
|
||||||
|
|
||||||
### Custom opencode config
|
### Custom opencode config
|
||||||
|
|
||||||
Mount your own `opencode.json` for full control (MCP servers, custom models, etc.):
|
For full control over opencode settings (MCP servers, custom models, oh-my-opencode-slim agents, etc.), mount the entire config directory from the host:
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
volumes:
|
volumes:
|
||||||
- ./my-opencode.json:/home/developer/.config/opencode/opencode.json:ro
|
- ~/.config/opencode:/home/developer/.config/opencode
|
||||||
|
```
|
||||||
|
|
||||||
|
This persists all configuration changes across container restarts, including `opencode.json`, `oh-my-opencode-slim.json`, and skills. When an existing `opencode.json` is found, the `OPENCODE_PROVIDER` auto-config is skipped.
|
||||||
|
|
||||||
|
### Custom skills
|
||||||
|
|
||||||
|
Mount agent skills from the host:
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
volumes:
|
||||||
|
- ~/.agents/skills:/home/developer/.agents/skills:ro
|
||||||
|
```
|
||||||
|
|
||||||
|
### Neovim configuration
|
||||||
|
|
||||||
|
The image includes neovim 0.12 with `EDITOR=nvim` set by default. To use your own neovim config (and have plugins auto-install via lazy.nvim on first start), mount it from the host:
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
volumes:
|
||||||
|
- ~/.config/nvim:/home/developer/.config/nvim:ro
|
||||||
|
```
|
||||||
|
|
||||||
|
### Python development with uv
|
||||||
|
|
||||||
|
The image includes Python 3.13 (from Debian Trixie) and [uv](https://docs.astral.sh/uv/), a fast Python package manager that replaces pip, venv, and pyenv:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Python 3.13 is available out of the box
|
||||||
|
python3 --version
|
||||||
|
|
||||||
|
# Use uv for package management
|
||||||
|
uv venv
|
||||||
|
uv pip install -r requirements.txt
|
||||||
|
|
||||||
|
# Or use uv's project workflow (reads pyproject.toml)
|
||||||
|
uv sync
|
||||||
|
|
||||||
|
# Run a Python script
|
||||||
|
uv run python script.py
|
||||||
|
|
||||||
|
# Install standalone Python tools
|
||||||
|
uvx ruff check .
|
||||||
|
|
||||||
|
# Install a newer Python version (persists with devbox-uv volume)
|
||||||
|
uv python install 3.14
|
||||||
|
```
|
||||||
|
|
||||||
|
Python installations are stored in `~/.local/share/uv/`. To persist them across container restarts, add the `devbox-uv` named volume to your `docker-compose.yml`:
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
volumes:
|
||||||
|
- devbox-uv:/home/developer/.local/share/uv
|
||||||
|
|
||||||
|
volumes:
|
||||||
|
devbox-uv:
|
||||||
|
```
|
||||||
|
|
||||||
|
Project virtual environments (`.venv`) are stored in your workspace directory and persist automatically via the `/workspace` bind mount.
|
||||||
|
|
||||||
|
### Rust development with rustup
|
||||||
|
|
||||||
|
The image includes `rustup-init`, the Rust toolchain installer. Rust is not pre-installed but can be bootstrapped on demand:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# One-time setup: install Rust toolchain (~300MB, persists with volumes)
|
||||||
|
rustup-init -y
|
||||||
|
source ~/.cargo/env
|
||||||
|
|
||||||
|
# Now use Rust normally
|
||||||
|
cargo new my-project
|
||||||
|
cargo build
|
||||||
|
cargo run
|
||||||
|
```
|
||||||
|
|
||||||
|
To persist Rust toolchains and cargo data across container restarts, add named volumes to your `docker-compose.yml`:
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
volumes:
|
||||||
|
- devbox-rustup:/home/developer/.rustup
|
||||||
|
- devbox-cargo:/home/developer/.cargo
|
||||||
|
|
||||||
|
volumes:
|
||||||
|
devbox-rustup:
|
||||||
|
devbox-cargo:
|
||||||
|
```
|
||||||
|
|
||||||
|
### JavaScript and TypeScript
|
||||||
|
|
||||||
|
The base image includes **Node.js 22** and **npm** — sufficient for most JavaScript and TypeScript development:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Initialize a new project
|
||||||
|
npm init -y
|
||||||
|
|
||||||
|
# Install dependencies
|
||||||
|
npm install
|
||||||
|
|
||||||
|
# Run TypeScript (via tsx, ts-node, etc.)
|
||||||
|
npx tsx src/index.ts
|
||||||
|
|
||||||
|
# Use npx for one-off tools
|
||||||
|
npx tsc --init
|
||||||
|
```
|
||||||
|
|
||||||
|
The OMOS image variant also includes **Bun**, a faster JavaScript runtime and package manager:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
bun init
|
||||||
|
bun install
|
||||||
|
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
|
### Rebuilding the Image
|
||||||
@@ -135,14 +297,100 @@ docker compose build --build-arg OPENCODE_VERSION=1.5.0
|
|||||||
|---|---|---|
|
|---|---|---|
|
||||||
| `INSTALL_PYTHON` | `false` | Python 3 + pip + venv |
|
| `INSTALL_PYTHON` | `false` | Python 3 + pip + venv |
|
||||||
| `INSTALL_GO` | `false` | Go toolchain |
|
| `INSTALL_GO` | `false` | Go toolchain |
|
||||||
|
| `INSTALL_OMOS` | `false` | [oh-my-opencode-slim](https://github.com/alvinunreal/oh-my-opencode-slim) multi-agent orchestration (installs Bun and plugin) |
|
||||||
|
| `OMOS_VERSION` | `latest` | Pin a specific oh-my-opencode-slim version |
|
||||||
|
|
||||||
|
## oh-my-opencode-slim (Multi-Agent Orchestration)
|
||||||
|
|
||||||
|
[oh-my-opencode-slim](https://github.com/alvinunreal/oh-my-opencode-slim) adds a multi-agent layer on top of opencode — an Orchestrator delegates tasks to specialized agents (Explorer, Oracle, Librarian, Designer, Fixer), each configurable with different models and providers.
|
||||||
|
|
||||||
|
### Setup
|
||||||
|
|
||||||
|
A pre-built OMOS image is available on Docker Hub as `joakimp/opencode-devbox:latest-omos`. Alternatively, build from source:
|
||||||
|
|
||||||
|
**1. Build the image with OMOS support:**
|
||||||
|
|
||||||
|
```bash
|
||||||
|
docker compose build --build-arg INSTALL_OMOS=true
|
||||||
|
```
|
||||||
|
|
||||||
|
This installs Bun and the oh-my-opencode-slim package into the image.
|
||||||
|
|
||||||
|
**2. Enable in `.env`:**
|
||||||
|
|
||||||
|
```bash
|
||||||
|
ENABLE_OMOS=true
|
||||||
|
```
|
||||||
|
|
||||||
|
**3. Run as normal:**
|
||||||
|
|
||||||
|
```bash
|
||||||
|
docker compose run --rm devbox
|
||||||
|
```
|
||||||
|
|
||||||
|
On first start, the entrypoint runs the oh-my-opencode-slim installer in non-interactive mode. It generates agent configuration at `~/.config/opencode/oh-my-opencode-slim.json` inside the container. The default preset uses OpenAI models — edit the generated config or mount your own to customize.
|
||||||
|
|
||||||
|
### OMOS Environment Variables
|
||||||
|
|
||||||
|
| Variable | Default | Description |
|
||||||
|
|---|---|---|
|
||||||
|
| `ENABLE_OMOS` | `false` | Activate oh-my-opencode-slim on container start |
|
||||||
|
| `OMOS_TMUX` | `false` | Enable tmux pane integration (tmux is included in the base image) |
|
||||||
|
| `OMOS_SKILLS` | `true` | Install recommended skills (simplify, agent-browser, cartography) |
|
||||||
|
| `OMOS_RESET` | `false` | Force regenerate config on next start (backs up existing config) |
|
||||||
|
|
||||||
|
### Custom Configuration
|
||||||
|
|
||||||
|
If you mount the opencode config directory (see Custom opencode config above), the `oh-my-opencode-slim.json` file is included and persists across restarts. Edit it directly to control which models power each agent, fallback chains, council setup, and more.
|
||||||
|
|
||||||
|
See the [oh-my-opencode-slim configuration docs](https://github.com/alvinunreal/oh-my-opencode-slim/blob/master/docs/configuration.md) for the full reference.
|
||||||
|
|
||||||
|
### Verifying Agents
|
||||||
|
|
||||||
|
After starting opencode with OMOS enabled, run inside the opencode session:
|
||||||
|
|
||||||
|
```
|
||||||
|
ping all agents
|
||||||
|
```
|
||||||
|
|
||||||
|
All six agents should respond if your provider authentication is working.
|
||||||
|
|
||||||
## AWS Bedrock Authentication
|
## AWS Bedrock Authentication
|
||||||
|
|
||||||
When using AWS Bedrock as your LLM provider, you need to authenticate via AWS SSO from inside the container. Since the container runs headless (no browser), use the device-code flow:
|
When using AWS Bedrock as your LLM provider, you need:
|
||||||
|
|
||||||
|
### 1. AWS config on the host
|
||||||
|
|
||||||
|
The container needs access to your `~/.aws/config` with SSO session configuration. If you already have this on another machine, copy it:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# Start the container interactively
|
scp -r user@other-machine:~/.aws ~/.aws
|
||||||
docker compose run --rm devbox bash
|
```
|
||||||
|
|
||||||
|
Or configure from scratch on the host:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
aws configure sso
|
||||||
|
```
|
||||||
|
|
||||||
|
### 2. Mount `~/.aws` into the container
|
||||||
|
|
||||||
|
Uncomment the AWS volume mount in `docker-compose.yml`:
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
- ~/.aws:/home/developer/.aws
|
||||||
|
```
|
||||||
|
|
||||||
|
Note: do **not** use `:ro` — SSO writes token cache files to this directory.
|
||||||
|
|
||||||
|
### 3. Authenticate inside the container
|
||||||
|
|
||||||
|
Since the container runs headless (no browser), use the device-code flow:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Start the container
|
||||||
|
docker compose up -d
|
||||||
|
docker compose exec -u developer devbox bash
|
||||||
|
|
||||||
# Authenticate — prints a URL and code you open in your local browser
|
# Authenticate — prints a URL and code you open in your local browser
|
||||||
aws sso login --sso-session <your-sso-session> --use-device-code
|
aws sso login --sso-session <your-sso-session> --use-device-code
|
||||||
@@ -153,7 +401,7 @@ opencode
|
|||||||
|
|
||||||
The `--use-device-code` flag outputs a URL and short code instead of trying to open a browser. Copy the URL into any browser (on your laptop, phone, etc.), enter the code, and complete the 2FA flow. The CLI in the container picks up the session automatically.
|
The `--use-device-code` flag outputs a URL and short code instead of trying to open a browser. Copy the URL into any browser (on your laptop, phone, etc.), enter the code, and complete the 2FA flow. The CLI in the container picks up the session automatically.
|
||||||
|
|
||||||
SSO sessions typically last 8–12 hours before requiring re-authentication.
|
SSO sessions typically last 8–12 hours before requiring re-authentication. Since `~/.aws` is mounted from the host, tokens persist across container restarts.
|
||||||
|
|
||||||
## Secret Scanning
|
## Secret Scanning
|
||||||
|
|
||||||
@@ -162,8 +410,11 @@ A [gitleaks](https://github.com/gitleaks/gitleaks) pre-commit hook prevents acci
|
|||||||
### Setup
|
### Setup
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
brew install gitleaks # one-time install
|
# macOS / Linuxbrew
|
||||||
./setup-hooks.sh # installs the pre-commit hook
|
brew install gitleaks
|
||||||
|
|
||||||
|
# Debian/Ubuntu (download binary)
|
||||||
|
curl -sSL https://github.com/gitleaks/gitleaks/releases/latest/download/gitleaks_$(uname -s)_$(uname -m).tar.gz | sudo tar -xz -C /usr/local/bin gitleaks
|
||||||
```
|
```
|
||||||
|
|
||||||
The hook runs automatically on every `git commit`. If gitleaks isn't installed, the hook prints a warning and allows the commit (no hard dependency on collaborators).
|
The hook runs automatically on every `git commit`. If gitleaks isn't installed, the hook prints a warning and allows the commit (no hard dependency on collaborators).
|
||||||
@@ -186,17 +437,37 @@ Allowlisted paths and rules are in `.gitleaks.toml`. The defaults extend gitleak
|
|||||||
Host Machine
|
Host Machine
|
||||||
├── ~/projects/my-app ──bind mount──▶ /workspace (container)
|
├── ~/projects/my-app ──bind mount──▶ /workspace (container)
|
||||||
├── ~/.ssh ──bind mount──▶ /home/developer/.ssh (ro)
|
├── ~/.ssh ──bind mount──▶ /home/developer/.ssh (ro)
|
||||||
|
├── ~/.aws ──bind mount──▶ /home/developer/.aws (Bedrock SSO)
|
||||||
└── .env ──env vars───▶ provider config + API keys
|
└── .env ──env vars───▶ provider config + API keys
|
||||||
|
|
||||||
Container (Debian bookworm)
|
Container (Debian trixie)
|
||||||
├── opencode binary
|
├── opencode binary
|
||||||
|
├── oh-my-opencode-slim (optional — multi-agent orchestration plugin, includes Bun)
|
||||||
├── AWS CLI v2 (SSO + Bedrock auth)
|
├── AWS CLI v2 (SSO + Bedrock auth)
|
||||||
├── git, ssh, ripgrep, fd, jq, curl, fzf
|
├── neovim 0.12, tmux, htop, bat, eza, zoxide, uv, rustup, make
|
||||||
|
├── git, ssh, ripgrep, fd, fzf, jq, curl, tree
|
||||||
├── Node.js (for MCP servers)
|
├── Node.js (for MCP servers)
|
||||||
├── entrypoint.sh (SSH perms, git config, provider setup)
|
├── Bun (optional — included with oh-my-opencode-slim)
|
||||||
|
├── entrypoint.sh (UID adjustment, git config, provider setup)
|
||||||
└── /workspace ← your code lives here
|
└── /workspace ← your code lives here
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Data persistence
|
||||||
|
|
||||||
|
| Path in container | Source | Survives `--rm`? | Contains |
|
||||||
|
|---|---|---|---|
|
||||||
|
| `/workspace` | Host bind mount | ✅ Yes | Your project files |
|
||||||
|
| `/home/developer/.ssh` | Host bind mount (ro) | ✅ Yes | SSH keys |
|
||||||
|
| `/home/developer/.aws` | Host bind mount (if configured) | ✅ Yes | AWS credentials/SSO cache |
|
||||||
|
| `/home/developer/.local/share/opencode` | Named volume `devbox-data` | ✅ Yes | Session history, memory |
|
||||||
|
| `/home/developer/.local/share/uv` | Named volume `devbox-uv` (if configured) | ✅ Yes | Python installs, uv tool installs |
|
||||||
|
| `/home/developer/.rustup` | Named volume `devbox-rustup` (if configured) | ✅ Yes | Rust toolchains |
|
||||||
|
| `/home/developer/.cargo` | Named volume `devbox-cargo` (if configured) | ✅ Yes | Cargo binaries, registry cache |
|
||||||
|
| `/home/developer/.vscode-server` | Named volume `devbox-vscode` (if configured) | ✅ Yes | VS Code server and extensions |
|
||||||
|
| `/home/developer/.config/opencode` | Host bind mount (if configured) | ✅ Yes | opencode.json, oh-my-opencode-slim.json, skills |
|
||||||
|
|
||||||
|
**opencode config** (`opencode.json`) is auto-generated from `OPENCODE_PROVIDER` on each start. It sets provider and model only — no MCP servers. To persist config changes and use custom settings, mount the config directory from the host (see Custom opencode config above).
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
MIT
|
MIT
|
||||||
|
|||||||
+30
-5
@@ -3,7 +3,7 @@
|
|||||||
# Usage:
|
# Usage:
|
||||||
# cp .env.example .env # configure your provider and keys
|
# cp .env.example .env # configure your provider and keys
|
||||||
# docker compose up -d
|
# docker compose up -d
|
||||||
# docker compose exec devbox opencode
|
# docker compose exec -u developer devbox opencode
|
||||||
#
|
#
|
||||||
# Or for interactive one-shot:
|
# Or for interactive one-shot:
|
||||||
# docker compose run --rm devbox
|
# docker compose run --rm devbox
|
||||||
@@ -15,6 +15,7 @@ services:
|
|||||||
args:
|
args:
|
||||||
INSTALL_PYTHON: "false"
|
INSTALL_PYTHON: "false"
|
||||||
INSTALL_GO: "false"
|
INSTALL_GO: "false"
|
||||||
|
INSTALL_OMOS: "false"
|
||||||
image: opencode-devbox:latest
|
image: opencode-devbox:latest
|
||||||
container_name: opencode-devbox
|
container_name: opencode-devbox
|
||||||
stdin_open: true
|
stdin_open: true
|
||||||
@@ -30,14 +31,38 @@ services:
|
|||||||
# SSH keys (read-only) — for git push/pull
|
# SSH keys (read-only) — for git push/pull
|
||||||
- ${SSH_KEY_PATH:-~/.ssh}:/home/developer/.ssh:ro
|
- ${SSH_KEY_PATH:-~/.ssh}:/home/developer/.ssh:ro
|
||||||
|
|
||||||
# Optional: mount your own opencode config
|
# Optional: mount opencode config directory (persists config changes across restarts)
|
||||||
# - ./config/opencode.json:/home/developer/.config/opencode/opencode.json:ro
|
# Includes opencode.json, oh-my-opencode-slim.json, skills, etc.
|
||||||
|
# When mounted, OPENCODE_PROVIDER auto-config is skipped if opencode.json exists.
|
||||||
|
# - ~/.config/opencode:/home/developer/.config/opencode
|
||||||
|
|
||||||
|
# Optional: mount opencode agent skills from host
|
||||||
|
# - ~/.agents/skills:/home/developer/.agents/skills:ro
|
||||||
|
|
||||||
|
# Optional: mount neovim config from host (plugins auto-install on first start)
|
||||||
|
# - ~/.config/nvim:/home/developer/.config/nvim:ro
|
||||||
|
|
||||||
# Optional: persist opencode data (auth, memory, etc.)
|
# Optional: persist opencode data (auth, memory, etc.)
|
||||||
- devbox-data:/home/developer/.local/share/opencode
|
- devbox-data:/home/developer/.local/share/opencode
|
||||||
|
|
||||||
# Optional: AWS credentials for Bedrock
|
# Optional: persist uv data (Python installs, tool installs)
|
||||||
# - ~/.aws:/home/developer/.aws:ro
|
# Without this, 'uv python install' must be re-run after container removal.
|
||||||
|
- devbox-uv:/home/developer/.local/share/uv
|
||||||
|
|
||||||
|
# Optional: persist Rust toolchains and cargo data
|
||||||
|
# Without this, 'rustup-init' must be re-run after container removal.
|
||||||
|
# - devbox-rustup:/home/developer/.rustup
|
||||||
|
# - devbox-cargo:/home/developer/.cargo
|
||||||
|
|
||||||
|
# Optional: persist VS Code server and extensions across container recreations
|
||||||
|
# - devbox-vscode:/home/developer/.vscode-server
|
||||||
|
|
||||||
|
# Optional: AWS credentials/SSO config (not read-only — SSO writes token cache)
|
||||||
|
# - ~/.aws:/home/developer/.aws
|
||||||
|
|
||||||
volumes:
|
volumes:
|
||||||
devbox-data:
|
devbox-data:
|
||||||
|
devbox-uv:
|
||||||
|
# devbox-rustup:
|
||||||
|
# devbox-cargo:
|
||||||
|
# devbox-vscode:
|
||||||
|
|||||||
@@ -0,0 +1,122 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
# ── Git config defaults ──────────────────────────────────────────────
|
||||||
|
if [ -n "${GIT_USER_NAME:-}" ] && ! git config --global user.name &>/dev/null; then
|
||||||
|
git config --global user.name "$GIT_USER_NAME"
|
||||||
|
fi
|
||||||
|
if [ -n "${GIT_USER_EMAIL:-}" ] && ! git config --global user.email &>/dev/null; then
|
||||||
|
git config --global user.email "$GIT_USER_EMAIL"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# ── Generate opencode config from env vars if no config mounted ──────
|
||||||
|
CONFIG_DIR="$HOME/.config/opencode"
|
||||||
|
CONFIG_FILE="$CONFIG_DIR/opencode.json"
|
||||||
|
|
||||||
|
if [ ! -f "$CONFIG_FILE" ] && [ -n "${OPENCODE_PROVIDER:-}" ]; then
|
||||||
|
echo "Generating opencode config for provider: $OPENCODE_PROVIDER"
|
||||||
|
mkdir -p "$CONFIG_DIR"
|
||||||
|
|
||||||
|
case "$OPENCODE_PROVIDER" in
|
||||||
|
anthropic)
|
||||||
|
cat > "$CONFIG_FILE" <<EOF
|
||||||
|
{
|
||||||
|
"\$schema": "https://opencode.ai/config.json",
|
||||||
|
"model": "${OPENCODE_MODEL:-anthropic/claude-sonnet-4-5}",
|
||||||
|
"share": "disabled",
|
||||||
|
"autoupdate": false
|
||||||
|
}
|
||||||
|
EOF
|
||||||
|
;;
|
||||||
|
openai)
|
||||||
|
cat > "$CONFIG_FILE" <<EOF
|
||||||
|
{
|
||||||
|
"\$schema": "https://opencode.ai/config.json",
|
||||||
|
"model": "${OPENCODE_MODEL:-openai/gpt-4o}",
|
||||||
|
"share": "disabled",
|
||||||
|
"autoupdate": false
|
||||||
|
}
|
||||||
|
EOF
|
||||||
|
;;
|
||||||
|
amazon-bedrock)
|
||||||
|
cat > "$CONFIG_FILE" <<EOF
|
||||||
|
{
|
||||||
|
"\$schema": "https://opencode.ai/config.json",
|
||||||
|
"model": "${OPENCODE_MODEL:-amazon-bedrock/anthropic.claude-sonnet-4-5-v1}",
|
||||||
|
"share": "disabled",
|
||||||
|
"autoupdate": false,
|
||||||
|
"provider": {
|
||||||
|
"amazon-bedrock": {
|
||||||
|
"options": {
|
||||||
|
"region": "${AWS_REGION:-us-east-1}",
|
||||||
|
"profile": "${AWS_PROFILE:-default}"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
EOF
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
cat > "$CONFIG_FILE" <<EOF
|
||||||
|
{
|
||||||
|
"\$schema": "https://opencode.ai/config.json",
|
||||||
|
"model": "${OPENCODE_MODEL:-anthropic/claude-sonnet-4-5}",
|
||||||
|
"share": "disabled",
|
||||||
|
"autoupdate": false
|
||||||
|
}
|
||||||
|
EOF
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
fi
|
||||||
|
|
||||||
|
# ── oh-my-opencode-slim setup (multi-agent orchestration) ────────────
|
||||||
|
# Activated by ENABLE_OMOS=true. Requires the image to be built with
|
||||||
|
# INSTALL_OMOS=true (which installs bun + the oh-my-opencode-slim package).
|
||||||
|
OMOS_CONFIG="$CONFIG_DIR/oh-my-opencode-slim.json"
|
||||||
|
|
||||||
|
if [ "${ENABLE_OMOS:-false}" = "true" ]; then
|
||||||
|
if ! command -v bunx &>/dev/null; then
|
||||||
|
echo "WARNING: ENABLE_OMOS=true but bun is not installed."
|
||||||
|
echo "Rebuild with: docker compose build --build-arg INSTALL_OMOS=true"
|
||||||
|
elif [ ! -f "$OMOS_CONFIG" ]; then
|
||||||
|
echo "Setting up oh-my-opencode-slim agents..."
|
||||||
|
|
||||||
|
# Determine installer flags
|
||||||
|
OMOS_TMUX_FLAG="no"
|
||||||
|
if [ "${OMOS_TMUX:-false}" = "true" ]; then
|
||||||
|
OMOS_TMUX_FLAG="yes"
|
||||||
|
fi
|
||||||
|
|
||||||
|
OMOS_SKILLS_FLAG="yes"
|
||||||
|
if [ "${OMOS_SKILLS:-true}" = "false" ]; then
|
||||||
|
OMOS_SKILLS_FLAG="no"
|
||||||
|
fi
|
||||||
|
|
||||||
|
bunx oh-my-opencode-slim@latest install \
|
||||||
|
--no-tui \
|
||||||
|
--tmux="${OMOS_TMUX_FLAG}" \
|
||||||
|
--skills="${OMOS_SKILLS_FLAG}"
|
||||||
|
|
||||||
|
echo "oh-my-opencode-slim configured successfully."
|
||||||
|
else
|
||||||
|
echo "oh-my-opencode-slim config found at $OMOS_CONFIG (use OMOS_RESET=true to overwrite)."
|
||||||
|
|
||||||
|
# Allow reset via env var (creates backup automatically)
|
||||||
|
if [ "${OMOS_RESET:-false}" = "true" ]; then
|
||||||
|
echo "OMOS_RESET=true — regenerating oh-my-opencode-slim config..."
|
||||||
|
OMOS_TMUX_FLAG="no"
|
||||||
|
[ "${OMOS_TMUX:-false}" = "true" ] && OMOS_TMUX_FLAG="yes"
|
||||||
|
OMOS_SKILLS_FLAG="yes"
|
||||||
|
[ "${OMOS_SKILLS:-true}" = "false" ] && OMOS_SKILLS_FLAG="no"
|
||||||
|
|
||||||
|
bunx oh-my-opencode-slim@latest install \
|
||||||
|
--no-tui \
|
||||||
|
--tmux="${OMOS_TMUX_FLAG}" \
|
||||||
|
--skills="${OMOS_SKILLS_FLAG}" \
|
||||||
|
--reset
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# ── Execute command ──────────────────────────────────────────────────
|
||||||
|
exec "$@"
|
||||||
+61
-76
@@ -1,84 +1,69 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
|
USER_NAME="developer"
|
||||||
|
CURRENT_UID=$(id -u "$USER_NAME")
|
||||||
|
CURRENT_GID=$(id -g "$USER_NAME")
|
||||||
|
|
||||||
|
# ── UID/GID adjustment ───────────────────────────────────────────────
|
||||||
|
# Priority: env vars > auto-detect from /workspace > default (1000)
|
||||||
|
TARGET_UID="${USER_UID:-}"
|
||||||
|
TARGET_GID="${USER_GID:-}"
|
||||||
|
|
||||||
|
# Auto-detect from /workspace owner if env vars not set
|
||||||
|
if [ -z "$TARGET_UID" ] && [ -d /workspace ]; then
|
||||||
|
WORKSPACE_UID=$(stat -c '%u' /workspace 2>/dev/null || stat -f '%u' /workspace 2>/dev/null)
|
||||||
|
WORKSPACE_GID=$(stat -c '%g' /workspace 2>/dev/null || stat -f '%g' /workspace 2>/dev/null)
|
||||||
|
# Only adjust if workspace is owned by a non-root user
|
||||||
|
if [ "$WORKSPACE_UID" != "0" ] && [ "$WORKSPACE_UID" != "$CURRENT_UID" ]; then
|
||||||
|
TARGET_UID="$WORKSPACE_UID"
|
||||||
|
TARGET_GID="${TARGET_GID:-$WORKSPACE_GID}"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Apply UID/GID changes if needed
|
||||||
|
if [ -n "$TARGET_GID" ] && [ "$TARGET_GID" != "$CURRENT_GID" ]; then
|
||||||
|
groupmod -g "$TARGET_GID" "$USER_NAME" 2>/dev/null || true
|
||||||
|
find /home/"$USER_NAME" -not -path "/home/$USER_NAME/.ssh/*" -group "$CURRENT_GID" -exec chgrp "$TARGET_GID" {} + 2>/dev/null || true
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -n "$TARGET_UID" ] && [ "$TARGET_UID" != "$CURRENT_UID" ]; then
|
||||||
|
usermod -u "$TARGET_UID" "$USER_NAME" 2>/dev/null || true
|
||||||
|
find /home/"$USER_NAME" -not -path "/home/$USER_NAME/.ssh/*" -user "$CURRENT_UID" -exec chown "$TARGET_UID" {} + 2>/dev/null || true
|
||||||
|
echo "Adjusted developer UID:GID to $TARGET_UID:${TARGET_GID:-$CURRENT_GID}"
|
||||||
|
fi
|
||||||
|
|
||||||
# ── SSH key permissions ──────────────────────────────────────────────
|
# ── SSH key permissions ──────────────────────────────────────────────
|
||||||
# If SSH keys are mounted, fix permissions (bind mounts may have wrong perms)
|
# If SSH keys are mounted, fix permissions (skip if read-only mount)
|
||||||
if [ -d "$HOME/.ssh" ] && [ "$(ls -A "$HOME/.ssh" 2>/dev/null)" ]; then
|
if [ -d "/home/$USER_NAME/.ssh" ] && [ "$(ls -A "/home/$USER_NAME/.ssh" 2>/dev/null)" ]; then
|
||||||
chmod 700 "$HOME/.ssh"
|
if touch "/home/$USER_NAME/.ssh/.perm_test" 2>/dev/null; then
|
||||||
find "$HOME/.ssh" -type f -name "id_*" ! -name "*.pub" -exec chmod 600 {} \; 2>/dev/null || true
|
rm -f "/home/$USER_NAME/.ssh/.perm_test"
|
||||||
find "$HOME/.ssh" -type f -name "*.pub" -exec chmod 644 {} \; 2>/dev/null || true
|
chmod 700 "/home/$USER_NAME/.ssh"
|
||||||
[ -f "$HOME/.ssh/known_hosts" ] && chmod 644 "$HOME/.ssh/known_hosts"
|
find "/home/$USER_NAME/.ssh" -type f -name "id_*" ! -name "*.pub" -exec chmod 600 {} \; 2>/dev/null || true
|
||||||
[ -f "$HOME/.ssh/config" ] && chmod 600 "$HOME/.ssh/config"
|
find "/home/$USER_NAME/.ssh" -type f -name "*.pub" -exec chmod 644 {} \; 2>/dev/null || true
|
||||||
|
[ -f "/home/$USER_NAME/.ssh/known_hosts" ] && chmod 644 "/home/$USER_NAME/.ssh/known_hosts"
|
||||||
|
[ -f "/home/$USER_NAME/.ssh/config" ] && chmod 600 "/home/$USER_NAME/.ssh/config"
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# ── Git config defaults ──────────────────────────────────────────────
|
# ── Fix ownership of named volume mount points ──────────────────────
|
||||||
# Set git config from env vars if not already configured via mounted .gitconfig
|
# Named volumes are created as root on first use. Fix ownership so the
|
||||||
if [ -n "${GIT_USER_NAME:-}" ] && ! git config --global user.name &>/dev/null; then
|
# developer user can write to them.
|
||||||
git config --global user.name "$GIT_USER_NAME"
|
FINAL_UID="${TARGET_UID:-$CURRENT_UID}"
|
||||||
fi
|
FINAL_GID="${TARGET_GID:-$CURRENT_GID}"
|
||||||
if [ -n "${GIT_USER_EMAIL:-}" ] && ! git config --global user.email &>/dev/null; then
|
for dir in \
|
||||||
git config --global user.email "$GIT_USER_EMAIL"
|
/home/"$USER_NAME"/.local/share/opencode \
|
||||||
|
/home/"$USER_NAME"/.local/share/uv \
|
||||||
|
/home/"$USER_NAME"/.rustup \
|
||||||
|
/home/"$USER_NAME"/.cargo \
|
||||||
|
/home/"$USER_NAME"/.vscode-server \
|
||||||
|
/home/"$USER_NAME"/.config/opencode \
|
||||||
|
/home/"$USER_NAME"/.config/nvim \
|
||||||
|
/home/"$USER_NAME"/.agents/skills; do
|
||||||
|
if [ -d "$dir" ] && [ "$(stat -c '%u' "$dir" 2>/dev/null)" != "$FINAL_UID" ]; then
|
||||||
|
chown -R "$FINAL_UID":"$FINAL_GID" "$dir" 2>/dev/null || true
|
||||||
fi
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
# ── Generate opencode config from env vars if no config mounted ──────
|
# ── Drop to developer user for remaining setup ──────────────────────
|
||||||
CONFIG_DIR="$HOME/.config/opencode"
|
exec gosu "$USER_NAME" /usr/local/bin/entrypoint-user.sh "$@"
|
||||||
CONFIG_FILE="$CONFIG_DIR/opencode.json"
|
|
||||||
|
|
||||||
if [ ! -f "$CONFIG_FILE" ] && [ -n "${OPENCODE_PROVIDER:-}" ]; then
|
|
||||||
echo "Generating opencode config for provider: $OPENCODE_PROVIDER"
|
|
||||||
mkdir -p "$CONFIG_DIR"
|
|
||||||
|
|
||||||
# Build provider-specific config
|
|
||||||
case "$OPENCODE_PROVIDER" in
|
|
||||||
anthropic)
|
|
||||||
cat > "$CONFIG_FILE" <<EOF
|
|
||||||
{
|
|
||||||
"\$schema": "https://opencode.ai/config.json",
|
|
||||||
"model": "${OPENCODE_MODEL:-anthropic/claude-sonnet-4-5}",
|
|
||||||
"share": "disabled",
|
|
||||||
"autoupdate": false
|
|
||||||
}
|
|
||||||
EOF
|
|
||||||
;;
|
|
||||||
openai)
|
|
||||||
cat > "$CONFIG_FILE" <<EOF
|
|
||||||
{
|
|
||||||
"\$schema": "https://opencode.ai/config.json",
|
|
||||||
"model": "${OPENCODE_MODEL:-openai/gpt-4o}",
|
|
||||||
"share": "disabled",
|
|
||||||
"autoupdate": false
|
|
||||||
}
|
|
||||||
EOF
|
|
||||||
;;
|
|
||||||
amazon-bedrock)
|
|
||||||
cat > "$CONFIG_FILE" <<EOF
|
|
||||||
{
|
|
||||||
"\$schema": "https://opencode.ai/config.json",
|
|
||||||
"model": "${OPENCODE_MODEL:-amazon-bedrock/anthropic.claude-sonnet-4-5-v1}",
|
|
||||||
"share": "disabled",
|
|
||||||
"autoupdate": false,
|
|
||||||
"provider": {
|
|
||||||
"amazon-bedrock": {
|
|
||||||
"options": {
|
|
||||||
"region": "${AWS_REGION:-us-east-1}"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
EOF
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
cat > "$CONFIG_FILE" <<EOF
|
|
||||||
{
|
|
||||||
"\$schema": "https://opencode.ai/config.json",
|
|
||||||
"model": "${OPENCODE_MODEL:-anthropic/claude-sonnet-4-5}",
|
|
||||||
"share": "disabled",
|
|
||||||
"autoupdate": false
|
|
||||||
}
|
|
||||||
EOF
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
fi
|
|
||||||
|
|
||||||
# ── Execute command ──────────────────────────────────────────────────
|
|
||||||
exec "$@"
|
|
||||||
|
|||||||
+2
-1
@@ -13,7 +13,8 @@ cat > "$HOOK_DIR/pre-commit" << 'HOOK'
|
|||||||
if ! command -v gitleaks >/dev/null 2>&1; then
|
if ! command -v gitleaks >/dev/null 2>&1; then
|
||||||
echo ""
|
echo ""
|
||||||
echo "⚠️ gitleaks is not installed — skipping secret scan"
|
echo "⚠️ gitleaks is not installed — skipping secret scan"
|
||||||
echo " Install: brew install gitleaks"
|
echo " Install: brew install gitleaks (macOS)"
|
||||||
|
echo " Or: curl -sSL https://github.com/gitleaks/gitleaks/releases/latest/download/gitleaks_\$(uname -s)_\$(uname -m).tar.gz | sudo tar -xz -C /usr/local/bin gitleaks"
|
||||||
echo ""
|
echo ""
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|||||||
Reference in New Issue
Block a user