Skip to content

Commit 61af349

Browse files
committed
Add opencode container
1 parent 49641d8 commit 61af349

File tree

6 files changed

+287
-0
lines changed

6 files changed

+287
-0
lines changed

.github/workflows/docker.yaml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,43 @@ jobs:
4747
tags: |
4848
ghcr.io/${{ github.repository_owner }}/${{ matrix.image }}:latest
4949
ghcr.io/${{ github.repository_owner }}/${{ matrix.image }}:${{ github.sha }}
50+
51+
devenv:
52+
permissions:
53+
contents: read
54+
packages: write
55+
runs-on: ubuntu-latest
56+
strategy:
57+
fail-fast: false
58+
matrix:
59+
image:
60+
- opencode
61+
62+
steps:
63+
- name: Check out repository
64+
uses: actions/checkout@v5
65+
66+
- name: Set up Docker Buildx
67+
uses: docker/setup-buildx-action@v3
68+
- uses: cachix/install-nix-action@v31
69+
- uses: cachix/cachix-action@v16
70+
with:
71+
name: devenv
72+
- name: Install devenv.sh
73+
run: nix profile add nixpkgs#devenv
74+
75+
- name: Log in to GHCR
76+
uses: docker/login-action@v3
77+
with:
78+
registry: ghcr.io
79+
username: ${{ github.actor }}
80+
password: ${{ secrets.GITHUB_TOKEN }}
81+
82+
- name: Push image
83+
run: |
84+
cd docker/${{ matrix.image }}
85+
devenv container build ${{ matrix.image }}
86+
devenv container \
87+
--registry docker://ghcr.io/${{ github.repository_owner }}/ \
88+
--copy-args="--dest-creds ${{ github.actor }}:${{ secrets.GITHUB_TOKEN }}" \
89+
copy ${{ matrix.image }}

docker/opencode/devenv.lock

Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
{
2+
"nodes": {
3+
"devenv": {
4+
"locked": {
5+
"dir": "src/modules",
6+
"lastModified": 1768597968,
7+
"owner": "cachix",
8+
"repo": "devenv",
9+
"rev": "92ad9c70fad164e8f4a3656dec91717a5c42cd98",
10+
"type": "github"
11+
},
12+
"original": {
13+
"dir": "src/modules",
14+
"owner": "cachix",
15+
"repo": "devenv",
16+
"type": "github"
17+
}
18+
},
19+
"flake-compat": {
20+
"flake": false,
21+
"locked": {
22+
"lastModified": 1767039857,
23+
"owner": "NixOS",
24+
"repo": "flake-compat",
25+
"rev": "5edf11c44bc78a0d334f6334cdaf7d60d732daab",
26+
"type": "github"
27+
},
28+
"original": {
29+
"owner": "NixOS",
30+
"repo": "flake-compat",
31+
"type": "github"
32+
}
33+
},
34+
"git-hooks": {
35+
"inputs": {
36+
"flake-compat": "flake-compat",
37+
"gitignore": "gitignore",
38+
"nixpkgs": [
39+
"nixpkgs"
40+
]
41+
},
42+
"locked": {
43+
"lastModified": 1767281941,
44+
"owner": "cachix",
45+
"repo": "git-hooks.nix",
46+
"rev": "f0927703b7b1c8d97511c4116eb9b4ec6645a0fa",
47+
"type": "github"
48+
},
49+
"original": {
50+
"owner": "cachix",
51+
"repo": "git-hooks.nix",
52+
"type": "github"
53+
}
54+
},
55+
"gitignore": {
56+
"inputs": {
57+
"nixpkgs": [
58+
"git-hooks",
59+
"nixpkgs"
60+
]
61+
},
62+
"locked": {
63+
"lastModified": 1762808025,
64+
"owner": "hercules-ci",
65+
"repo": "gitignore.nix",
66+
"rev": "cb5e3fdca1de58ccbc3ef53de65bd372b48f567c",
67+
"type": "github"
68+
},
69+
"original": {
70+
"owner": "hercules-ci",
71+
"repo": "gitignore.nix",
72+
"type": "github"
73+
}
74+
},
75+
"mk-shell-bin": {
76+
"locked": {
77+
"lastModified": 1677004959,
78+
"owner": "rrbutani",
79+
"repo": "nix-mk-shell-bin",
80+
"rev": "ff5d8bd4d68a347be5042e2f16caee391cd75887",
81+
"type": "github"
82+
},
83+
"original": {
84+
"owner": "rrbutani",
85+
"repo": "nix-mk-shell-bin",
86+
"type": "github"
87+
}
88+
},
89+
"nix2container": {
90+
"inputs": {
91+
"nixpkgs": [
92+
"nixpkgs"
93+
]
94+
},
95+
"locked": {
96+
"lastModified": 1767430085,
97+
"owner": "nlewo",
98+
"repo": "nix2container",
99+
"rev": "66f4b8a47e92aa744ec43acbb5e9185078983909",
100+
"type": "github"
101+
},
102+
"original": {
103+
"owner": "nlewo",
104+
"repo": "nix2container",
105+
"type": "github"
106+
}
107+
},
108+
"nixpkgs": {
109+
"locked": {
110+
"lastModified": 1767052823,
111+
"owner": "cachix",
112+
"repo": "devenv-nixpkgs",
113+
"rev": "538a5124359f0b3d466e1160378c87887e3b51a4",
114+
"type": "github"
115+
},
116+
"original": {
117+
"owner": "cachix",
118+
"ref": "rolling",
119+
"repo": "devenv-nixpkgs",
120+
"type": "github"
121+
}
122+
},
123+
"root": {
124+
"inputs": {
125+
"devenv": "devenv",
126+
"git-hooks": "git-hooks",
127+
"mk-shell-bin": "mk-shell-bin",
128+
"nix2container": "nix2container",
129+
"nixpkgs": "nixpkgs",
130+
"pre-commit-hooks": [
131+
"git-hooks"
132+
]
133+
}
134+
}
135+
},
136+
"root": "root",
137+
"version": 7
138+
}

docker/opencode/devenv.nix

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{ pkgs, ... }: {
2+
languages = {
3+
rust.enable = true;
4+
python.enable = true;
5+
javascript = {
6+
enable = true;
7+
npm.enable = true;
8+
yarn.enable = true;
9+
bun.enable = true;
10+
pnpm.enable = true;
11+
};
12+
};
13+
14+
packages = with pkgs; [
15+
opencode
16+
ripgrep
17+
fd
18+
];
19+
20+
containers."opencode" = {
21+
name = "opencode";
22+
registry = "docker://ghcr.io/dzervas/";
23+
24+
copyToRoot = [];
25+
startupCommand = "${pkgs.opencode}/bin/opencode web";
26+
};
27+
}

docker/opencode/devenv.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
inputs:
2+
mk-shell-bin:
3+
url: github:rrbutani/nix-mk-shell-bin
4+
nix2container:
5+
url: github:nlewo/nix2container
6+
inputs:
7+
nixpkgs:
8+
follows: nixpkgs

envs/opencode/main.jsonnet

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
local dockerService = import 'docker-service.libsonnet';
2+
local timezone = import 'helpers/timezone.libsonnet';
3+
local k = import 'k.libsonnet';
4+
5+
local namespace = 'opencode';
6+
local image = 'ghcr.io/dzervas/opencode:latest';
7+
local dataPath = '/data';
8+
local configPath = '/config';
9+
10+
local serverArgs = ['web', '--hostname', '0.0.0.0', '--port', '4096'];
11+
local configFile = configPath + '/opencode.json';
12+
13+
local opencode = dockerService.new('opencode', image, {
14+
namespace: namespace,
15+
ports: [4096],
16+
fqdn: 'opencode.vpn.dzerv.art',
17+
runAsUser: 1000,
18+
19+
command: ['opencode'],
20+
args: serverArgs,
21+
22+
env: {
23+
TZ: timezone,
24+
OPENCODE_CONFIG: configFile,
25+
XDG_DATA_HOME: dataPath,
26+
},
27+
28+
op_envs: {
29+
OPENCODE_SERVER_PASSWORD: 'server-password',
30+
},
31+
32+
pvs: {
33+
[dataPath]: {
34+
name: 'data',
35+
size: '20Gi',
36+
},
37+
},
38+
39+
config_maps: {
40+
[configPath]: 'opencode-config:ro',
41+
},
42+
});
43+
44+
local configMap = k.core.v1.configMap.new('opencode-config')
45+
+ k.core.v1.configMap.metadata.withNamespace(namespace)
46+
+ k.core.v1.configMap.withData({
47+
'opencode.json': std.manifestJsonEx({
48+
'$schema': 'https://opencode.ai/config.json',
49+
server: {
50+
hostname: '0.0.0.0',
51+
port: 4096,
52+
},
53+
}, ' '),
54+
});
55+
56+
{
57+
opencode: opencode,
58+
opencodeConfig: configMap,
59+
}

envs/opencode/spec.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"apiVersion": "tanka.dev/v1alpha1",
3+
"kind": "Environment",
4+
"metadata": {
5+
"name": "envs/opencode"
6+
},
7+
"spec": {
8+
"contextNames": ["gr"],
9+
"namespace": "opencode",
10+
"injectLabels": true,
11+
"applyStrategy": "server",
12+
"resourceDefaults": {},
13+
"expectVersions": {}
14+
}
15+
}

0 commit comments

Comments
 (0)