Skip to content

Commit 856795f

Browse files
committed
chore: move files
1 parent 5da5e3c commit 856795f

7 files changed

Lines changed: 140 additions & 155 deletions

File tree

File renamed without changes.

README.md

Lines changed: 81 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,83 @@
1-
# codeplace
2-
Cloud for Opencode
1+
# sprisa/opencode
32

4-
## Projects
3+
A general-purpose Ubuntu Docker image for running [opencode](https://opencode.ai). Published to Docker Hub as `sprisa/opencode:<version>` where `<version>` matches the release pinned in `version.txt`.
54

6-
- **[opencode/](opencode/)**`sprisa/opencode`: Ubuntu-based Docker image for running opencode as a long-lived dev server. See [opencode/README.md](opencode/README.md) for usage.
5+
## What's inside
6+
7+
| Layer | Details |
8+
|---|---|
9+
| **Base OS** | ubuntu:26.04 |
10+
| **User** | `opencode` (uid/gid 1000), passwordless sudo |
11+
| **opencode** | Pinned in `version.txt` as `OPENCODE_VERSION` build arg |
12+
| **Node.js** | Current LTS via `n`, installed to `/opt/n` (outside home) |
13+
| **Python 3** | pip, venv |
14+
| **Build tools** | `build-essential`, `pkg-config` (for native npm addons, pip source builds) |
15+
| **CLI utilities** | git, curl, wget, jq, ripgrep, fd-find, vim, nano, less, unzip, ssh client |
16+
| **Init** | tini as PID 1 (zombie reaping, clean shutdown) |
17+
18+
## Usage
19+
20+
### Quick start
21+
22+
```bash
23+
docker run -it -p 4096:4096 -v $(pwd):/home/opencode sprisa/opencode:latest
24+
```
25+
26+
The server starts on port 4096. Mount your project at `/home/opencode` to persist the entire home directory (dotfiles, config, and `~/workspace`).
27+
28+
### Environment variables
29+
30+
| Variable | Default | Description |
31+
|---|---|---|
32+
| `OPENCODE_PORT` | `4096` | Port the server listens on |
33+
| `OPENCODE_SERVER_PASSWORD` | *(none)* | Optional auth password for the server |
34+
| `OPENCODE_CORS_ORIGIN` | *(none)* | Optional CORS origin; omit to disable CORS |
35+
36+
### Examples
37+
38+
**With authentication:**
39+
```bash
40+
docker run -it -p 4096:4096 \
41+
-e OPENCODE_SERVER_PASSWORD=secret \
42+
-v myproject:/home/opencode \
43+
sprisa/opencode:latest
44+
```
45+
46+
**With CORS enabled for a specific origin:**
47+
```bash
48+
docker run -it -p 4096:4096 \
49+
-e OPENCODE_CORS_ORIGIN=https://myapp.example.com \
50+
sprisa/opencode:latest
51+
```
52+
53+
**Custom port:**
54+
```bash
55+
docker run -it -p 8080:8080 \
56+
-e OPENCODE_PORT=8080 \
57+
sprisa/opencode:latest
58+
```
59+
60+
## Building & pushing
61+
62+
All docker commands go through `task` which reads the pinned version from `version.txt`:
63+
64+
```bash
65+
task docker:build # Build locally as sprisa/opencode:<version>
66+
task docker:login # Docker Hub login (needs $DOCKER_USER / $DOCKER_PASS)
67+
task docker:push # Push +latest and +<version> for amd64/arm64
68+
```
69+
70+
## Updating the opencode version
71+
72+
```bash
73+
task update-version
74+
```
75+
76+
Fetches the latest release from [anomalyco/opencode](https://github.com/anomalyco/opencode) on GitHub and writes it to `version.txt`.
77+
78+
## Runtime notes
79+
80+
- The `opencode` user has passwordless sudo, so you can `su - opencode -c 'apt install <pkg>'` inside the container.
81+
- The root filesystem is ephemeral; mount `/home/opencode` as the persistent volume for all user data (dotfiles, config, projects). The `~/workspace` subdirectory is the default workdir.
82+
- `~/.local/bin` is on PATH and user-writable, useful for dropping custom tools at runtime.
83+
- Node version can be switched at runtime with `n <version>` (e.g. `n lts`).

Taskfile.yml

Lines changed: 59 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,67 @@
1-
# yaml-language-server: $schema=https://taskfile.dev/schema.json
1+
# Taskfile for sprisa/opencode Docker image.
2+
# Install go-task: https://taskfile.dev/installation/ (brew install go-task)
3+
# Run `task` (or `task --list`) to see available commands.
4+
version: "3"
25

3-
version: '3'
6+
vars:
7+
REGISTRY: docker.io
8+
OWNER: sprisa
9+
IMAGE: opencode
10+
REPO: "{{.OWNER}}/{{.IMAGE}}"
11+
OCI: "{{.REGISTRY}}/{{.OWNER}}/{{.IMAGE}}"
12+
VERSION:
13+
sh: cat version.txt | tr -d '[:space:]'
414

515
tasks:
616
default:
717
desc: List available tasks
818
cmds:
919
- task --list
1020
silent: true
21+
22+
update-version:
23+
desc: Fetch latest opencode release version from GitHub and update version.txt
24+
preconditions:
25+
- sh: command -v curl >/dev/null
26+
msg: "curl not found"
27+
- sh: command -v jq >/dev/null
28+
msg: "jq not found. Install it: brew install jq"
29+
cmds:
30+
- |
31+
LATEST=$(curl -fsSL https://api.github.com/repos/anomalyco/opencode/releases/latest \
32+
| jq -r '.tag_name' | sed 's/^v//')
33+
CURRENT=$(cat version.txt | tr -d '[:space:]')
34+
if [ "$LATEST" != "$CURRENT" ]; then
35+
echo "$LATEST" > version.txt
36+
echo "Updated: $CURRENT -> $LATEST"
37+
else
38+
echo "Already at latest: $CURRENT"
39+
fi
40+
41+
docker:build:
42+
desc: "Build the image locally (tag: sprisa/opencode:<version>)"
43+
cmds:
44+
- "docker build --build-arg OPENCODE_VERSION={{.VERSION}} -t {{.OCI}}:{{.VERSION}} ."
45+
46+
docker:push:
47+
desc: "Build and push multi-arch to Docker Hub with <version> and :latest tags"
48+
cmds:
49+
- |
50+
docker buildx build \
51+
--platform linux/amd64,linux/arm64 \
52+
--build-arg OPENCODE_VERSION={{.VERSION}} \
53+
--push \
54+
-t {{.OCI}}:{{.VERSION}} \
55+
-t {{.OCI}}:latest \
56+
.
57+
- "echo Pushed {{.OCI}}:{{.VERSION}} and {{.OCI}}:latest"
58+
59+
docker:login:
60+
desc: "Log in to Docker Hub (needs $DOCKER_USER and $DOCKER_PASS)"
61+
preconditions:
62+
- sh: '[ -n "$DOCKER_USER" ]'
63+
msg: "Set DOCKER_USER"
64+
- sh: '[ -n "$DOCKER_PASS" ]'
65+
msg: "Set DOCKER_PASS (use a Docker Hub access token)"
66+
cmds:
67+
- "echo $DOCKER_PASS | docker login -u $DOCKER_USER --password-stdin"
File renamed without changes.

opencode/README.md

Lines changed: 0 additions & 83 deletions
This file was deleted.

opencode/Taskfile.yml

Lines changed: 0 additions & 66 deletions
This file was deleted.
File renamed without changes.

0 commit comments

Comments
 (0)