Skip to content

Commit 737c426

Browse files
committed
docs: add OpenCode injector image Dockerfile and registry.json guide
- Replace Gemini/Claude dual-provider example with a single OpenCode provider using OPENAI_API_KEY - Add Procedure step with a minimal Dockerfile for building a custom injector image, based on che-incubator/che-ai-tool-images/dockerfiles/ opencode/Dockerfile; explains multi-stage build, wrapper script for OpenShift arbitrary UIDs, and multi-arch build command - Reference che-incubator/che-ai-tool-images for maintained examples - Document all registry.json fields with numbered callouts Assisted-by: Claude Sonnet 4.6 Signed-off-by: Oleksii Orel <oorel@redhat.com>
1 parent fd30633 commit 737c426

1 file changed

Lines changed: 84 additions & 42 deletions

File tree

modules/administration-guide/pages/configuring-ai-providers.adoc

Lines changed: 84 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
:_content-type: PROCEDURE
22
:description: Register AI providers in Eclipse Che so that developers can select and use AI coding assistants when creating workspaces.
3-
:keywords: administration, ai, ai provider, gemini, claude, configmap, ai-tool-registry, api key
3+
:keywords: administration, ai, ai provider, opencode, configmap, ai-tool-registry, api key, injector image, dockerfile
44
:navtitle: Configuring AI providers
55
:page-aliases:
66

@@ -22,61 +22,103 @@ The AI tool registry is stored in a {kubernetes} `ConfigMap` with specific label
2222

2323
.Procedure
2424

25-
. Create a `registry.json` file defining providers, tools, and default selections:
25+
. Optional: Build and push a custom AI tool injector image.
26+
+
27+
The injector image is a container that carries the AI tool binary. During workspace startup, {prod-short} runs it as an init container to copy the binary into a shared volume. The following minimal `Dockerfile` is based on the link:https://github.com/che-incubator/che-ai-tool-images/blob/main/dockerfiles/opencode/Dockerfile[OpenCode injector image]:
28+
+
29+
[source,dockerfile]
30+
----
31+
FROM alpine:3.21 AS builder
32+
33+
ARG OPENCODE_VERSION=v1.2.27
34+
ARG TARGETARCH
35+
36+
RUN apk add --no-cache curl tar gzip
37+
38+
RUN set -e && \
39+
case "${TARGETARCH}" in \
40+
amd64) ARCH="x64" ;; \
41+
arm64) ARCH="arm64" ;; \
42+
*) echo "Unsupported architecture: ${TARGETARCH}" && exit 1 ;; \
43+
esac && \
44+
curl -fsSL -o /tmp/opencode.tar.gz \
45+
"https://github.com/anomalyco/opencode/releases/download/${OPENCODE_VERSION}/opencode-linux-${ARCH}.tar.gz" && \
46+
tar -xzf /tmp/opencode.tar.gz -C /tmp && \
47+
mv /tmp/opencode /usr/local/bin/opencode && \
48+
chmod +x /usr/local/bin/opencode
49+
50+
FROM registry.access.redhat.com/ubi10/ubi-minimal:10.0
51+
52+
COPY --from=builder /usr/local/bin/opencode /usr/local/bin/opencode-bin
53+
54+
RUN printf '#!/bin/sh\n\
55+
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"\n\
56+
OC_HOME="/tmp/opencode-home"\n\
57+
mkdir -p "$OC_HOME/.config" "$OC_HOME/.local/share"\n\
58+
export XDG_CONFIG_HOME="${XDG_CONFIG_HOME:-$OC_HOME/.config}"\n\
59+
export XDG_DATA_HOME="${XDG_DATA_HOME:-$OC_HOME/.local/share}"\n\
60+
exec "$SCRIPT_DIR/opencode-bin" "$@"\n' > /usr/local/bin/opencode && \
61+
chmod +x /usr/local/bin/opencode
62+
63+
LABEL org.opencontainers.image.description="OpenCode CLI tool for DevWorkspace injection" \
64+
org.opencontainers.image.source="https://github.com/che-incubator/che-ai-tool-images.git"
65+
----
66+
+
67+
Key design points:
68+
+
69+
** *Multi-stage build*: the `builder` stage downloads the architecture-specific binary; the minimal runtime stage keeps the final image small.
70+
** *Wrapper script*: redirects `XDG_CONFIG_HOME`, `XDG_DATA_HOME`, and related variables to writable paths under `/tmp`, allowing the tool to run as an arbitrary UID on OpenShift.
71+
** *Multi-arch*: pass `--platform linux/amd64,linux/arm64` to `docker build` to produce a multi-arch image.
72+
+
73+
Build and push the image:
74+
+
75+
[subs="+quotes"]
76+
----
77+
$ docker build --platform linux/amd64,linux/arm64 \
78+
-t __<your-registry>__/__<your-org>__/opencode:next \
79+
--push .
80+
----
81+
+
82+
See link:https://github.com/che-incubator/che-ai-tool-images[che-incubator/che-ai-tool-images] for maintained injector image examples.
83+
84+
. Create a `registry.json` file that defines providers, tools, and optional defaults:
2685
+
2786
[source,json,subs="+quotes"]
2887
----
2988
{
3089
"providers": [
3190
{
32-
"id": "google/gemini",
33-
"name": "Gemini",
34-
"publisher": "Google",
35-
"description": "Google Gemini AI assistant for the terminal.",
36-
"docsUrl": "https://ai.google.dev/gemini-api/docs/quickstart",
37-
"icon": "https://example.com/gemini-icon.svg"
38-
},
39-
{
40-
"id": "anthropic/claude",
41-
"name": "Claude",
42-
"publisher": "Anthropic",
43-
"description": "Anthropic Claude AI coding assistant for terminal.",
44-
"docsUrl": "https://docs.anthropic.com/claude/reference/getting-started-with-the-api",
45-
"icon": "https://example.com/claude-icon.svg"
91+
"id": "opencodeai/opencode", <1>
92+
"name": "OpenCode",
93+
"publisher": "opencode.ai",
94+
"description": "Open-source terminal AI coding agent supporting 75+ LLM providers.",
95+
"docsUrl": "https://opencode.ai",
96+
"icon": "https://example.com/opencode-icon.svg"
4697
}
4798
],
4899
"tools": [
49100
{
50-
"providerId": "google/gemini", <1>
51-
"tag": "next", <2>
52-
"name": "Gemini CLI",
53-
"url": "https://ai.google.dev/gemini-api/docs",
54-
"binary": "gemini", <3>
55-
"pattern": "bundle", <4>
56-
"injectorImage": "quay.io/example/gemini-cli:next", <5>
57-
"envVarName": "GEMINI_API_KEY" <6>
58-
},
59-
{
60-
"providerId": "anthropic/claude",
61-
"tag": "next",
62-
"name": "Claude Code",
63-
"url": "https://claude.ai/code",
64-
"binary": "claude",
65-
"pattern": "init",
66-
"injectorImage": "quay.io/example/claude-code:next",
67-
"envVarName": "ANTHROPIC_API_KEY"
101+
"providerId": "opencodeai/opencode", <2>
102+
"tag": "next", <3>
103+
"name": "OpenCode",
104+
"url": "https://opencode.ai",
105+
"binary": "opencode", <4>
106+
"pattern": "init", <5>
107+
"injectorImage": "__<your-registry>__/__<your-org>__/opencode:next", <6>
108+
"envVarName": "OPENAI_API_KEY" <7>
68109
}
69110
],
70-
"defaultAiProviders": ["google/gemini"] <7>
111+
"defaultAiProviders": ["opencodeai/opencode"] <8>
71112
}
72113
----
73-
<1> Links the tool to a provider by the provider's `id`.
74-
<2> Version tag. When multiple tools share the same `providerId`, the dashboard selects by tag priority: `next` > `latest` > highest semver.
75-
<3> Binary name available in `PATH` after injection.
76-
<4> Injection pattern: `init` copies a single binary; `bundle` copies a full runtime directory and creates a symlink.
77-
<5> Container image used as an init container to copy the tool binary into a shared volume.
78-
<6> Environment variable name for the API key. The dashboard creates a {kubernetes} Secret with this key.
79-
<7> Optional. List of provider IDs pre-selected in the AI Selector widget for new workspaces.
114+
<1> Unique provider identifier in `__<vendor>__/__<product>__` format.
115+
<2> Links the tool to its provider by `id`.
116+
<3> Version tag. When multiple tools share the same `providerId`, the dashboard selects by priority: `next` > `latest` > highest semver.
117+
<4> Binary name that must be available in `PATH` inside the workspace after injection.
118+
<5> Injection pattern: `init` copies a single binary into the shared volume; `bundle` copies a full runtime directory and creates a symlink.
119+
<6> Container image that carries the tool binary. Run as an init container at workspace start.
120+
<7> Environment variable name for the API key. The dashboard creates a {kubernetes} Secret using this name as the data key.
121+
<8> Optional. Provider IDs pre-selected in the AI Selector widget for new workspaces.
80122

81123
. Create the `ConfigMap` in the `{prod-namespace}` namespace with the required labels:
82124
+

0 commit comments

Comments
 (0)