[PR #9560] feat: Debian-based full-stack Opencode Docker image (incl. OpenTelemetry) with GitHub build workflow for … #13148

Open
opened 2026-02-16 18:18:01 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/anomalyco/opencode/pull/9560

State: open
Merged: No


Issue fixed

https://github.com/anomalyco/opencode/issues/9562

How did you verify your code works?

The image build executed successfully on my clone of this repo in the branch used to submit this PR: see https://github.com/didier-durand/opencode/actions/runs/21161964252/job/60858222994

The container registry was successfully created on my clone: https://github.com/didier-durand/opencode/pkgs/container/opencode.

The built image runs fine on my MacOS laptop:
image

What does this PR do?

This PR mostly delivers a full-stack Docker image (based on Debian Trixie official image) for Opencode to operate
consistently across multiple environments (developer laptop, on-prem K8s pod, cloud service like AWS ECS or GCP Run
functions). Having such an image avoid setup issues in new environments and fosters repeatability across those environments

Running in Docker, Opencode still works fine with Ghostty or Alacritty.
To try the image interactively, just run in Ghostty:
docker run -it ghcr.io/didier-durand/opencode-vibe:latest opencode --log-level INFO --model opencode/glm-4.7-free --prompt 'who are you?'

To try the build locally: docker build --no-cache --tag opencode:latest .
To run the locally built image: docker run -it opencode:latest opencode --log-level INFO --model opencode/glm-4.7-free --prompt 'who are you?'

This image is fully validated in the GitHub worklfow after its build with a very similar command using opencode run with same free model.
You can see multiple executions of this workflow in repo opencode-vibe

The image embarks OpenTelemetry collector to make the Opencode agents fully observable (logs, trace spans,
metrics) as enabled by Vercel's AI SDK which is leveraged by Opencode. In our own use cases, we heavily leverage
OpenTelemetry observability with Dash0 service as backend.

Screenshot 2026-01-20 at 07 10 24

Here is an example with Opencode logs

The deliverables of the PRare:

  • The Dockerfile
  • The YAML of GitHub workflow
  • The config file for OpenTelemetry collector
  • The directive file for [Hadolint]https://github.com/hadolint/hadolint) to check the Dockerfile

The Dockerfile will:

  1. update the Trixie image to the last version for all packages
  2. add additional packages like curl, jq, etc. that LLMs tend to use to install tools, analyze code
  3. install Python (currently 3.13) and uv package manager as LLMs often generate Python scripts and instruct agents to run those when they
    realize that running a generated ad hoc script will prove more efficient than a ton of tool calls
  4. install OpenTelemetry collector and its community contributions (to obtain filelog). The use of filelog contrib
    will allow the upload of Opencode log files to OpenTelemetry backend (see screenshot above)
  5. install Opencode with its config and its extensions in .opencode directory
  6. create a opencode user to have a proper home directory to host .opencode directory and other config files
  7. create a start bash shell using the WITH_OTEL env var to be supplied at run time by docker run command to activate OpenTelemetry or not

The GitHub workflow will:

  1. run every 12h to cope with rapid evolution pace of Opencode
  2. validate the Dockerfile via Hadolint and the Opencode config file against official Opencode schema via check-jsonschema
  3. prepare the tags for the image to be built
  4. build a new Docker image of full-stack Opencode with the last version pushed to NPM official registry
  5. push this image to a GitHub container registry named after the repository name, i.e. ghcr.io/anomalyco/opencode in this case

Finally, the workflow will:

  1. download the newly created image
  2. validate executions Opencode will run under created user opencode
  3. check that the version of Opencode installed in container matches the one used at built time
  4. validate that the Opencode agent runs properly via the execution of a simple prompt as a docker run command leveraging a free Opencode model:
    `docker exec "$CONTAINER_NAME" opencode run --log-leve
**Original Pull Request:** https://github.com/anomalyco/opencode/pull/9560 **State:** open **Merged:** No --- ### Issue fixed https://github.com/anomalyco/opencode/issues/9562 ### How did you verify your code works? The image build executed successfully on my clone of this repo in the branch used to submit this PR: see [https://github.com/didier-durand/opencode/actions/runs/21161964252/job/60858222994](https://github.com/didier-durand/opencode/actions/runs/21161964252/job/60858222994 ) The container registry was successfully created on my clone: https://github.com/didier-durand/opencode/pkgs/container/opencode. The built image runs fine on my MacOS laptop: <img width="1569" height="585" alt="image" src="https://github.com/user-attachments/assets/5947bda2-1422-4bcf-ae12-134fb949a04a" /> ### What does this PR do? This PR mostly delivers a full-stack Docker image (based on Debian Trixie official image) for Opencode to operate consistently across multiple environments (developer laptop, on-prem K8s pod, cloud service like AWS ECS or GCP Run functions). Having such an image avoid setup issues in new environments and fosters repeatability across those environments Running in Docker, Opencode still works fine with Ghostty or Alacritty. To try the image interactively, just run in Ghostty: `docker run -it ghcr.io/didier-durand/opencode-vibe:latest opencode --log-level INFO --model opencode/glm-4.7-free --prompt 'who are you?'` To try the build locally: `docker build --no-cache --tag opencode:latest .` To run the locally built image: `docker run -it opencode:latest opencode --log-level INFO --model opencode/glm-4.7-free --prompt 'who are you?'` This image is fully validated in the GitHub worklfow after its build with a very similar command using `opencode run` with same free model. You can see multiple executions of this workflow in repo [opencode-vibe](https://github.com/didier-durand/opencode-vibe/actions/workflows/build-docker-opencode.yaml) The image embarks OpenTelemetry collector to make the Opencode agents fully observable (logs, trace spans, metrics) as enabled by Vercel's AI SDK which is leveraged by Opencode. In our own use cases, we heavily leverage OpenTelemetry observability with [Dash0 service](https://www.dash0.com/) as backend. <img width="1691" height="737" alt="Screenshot 2026-01-20 at 07 10 24" src="https://github.com/user-attachments/assets/ecd7a2ee-2459-4740-9199-b0464f475e2d" /> Here is an example with Opencode logs The deliverables of the PRare: * The Dockerfile * The YAML of GitHub workflow * The config file for OpenTelemetry collector * The directive file for [Hadolint]https://github.com/hadolint/hadolint) to check the Dockerfile The Dockerfile will: 1. update the Trixie image to the last version for all packages 2. add additional packages like curl, jq, etc. that LLMs tend to use to install tools, analyze code 3. install Python (currently 3.13) and uv package manager as LLMs often generate Python scripts and instruct agents to run those when they realize that running a generated ad hoc script will prove more efficient than a ton of tool calls 4. install OpenTelemetry collector and its community contributions (to obtain filelog). The use of filelog contrib will allow the upload of Opencode log files to OpenTelemetry backend (see screenshot above) 5. install Opencode with its config and its extensions in .opencode directory 6. create a `opencode` user to have a proper home directory to host .opencode directory and other config files 7. create a start bash shell using the `WITH_OTEL` env var to be supplied at run time by `docker run` command to activate OpenTelemetry or not The GitHub workflow will: 1. run every 12h to cope with rapid evolution pace of Opencode 2. validate the Dockerfile via `Hadolint` and the Opencode config file against official Opencode schema via `check-jsonschema` 3. prepare the tags for the image to be built 4. build a new Docker image of full-stack Opencode with the last version pushed to NPM official registry 5. push this image to a GitHub container registry named after the repository name, i.e. `ghcr.io/anomalyco/opencode` in this case Finally, the workflow will: 1. download the newly created image 2. validate executions Opencode will run under created user `opencode` 3. check that the version of Opencode installed in container matches the one used at built time 4. validate that the Opencode agent runs properly via the execution of a simple prompt as a docker run command leveraging a free Opencode model: `docker exec "$CONTAINER_NAME" opencode run --log-leve
yindo added the pull-request label 2026-02-16 18:18:01 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#13148