OpenCode Docker sandbox

Dagu Docker sandbox से OpenCode चलाएं।

OpenCode की non-interactive command opencode run है। opencode binary और provider credentials को runner container में रखें, फिर Dagu harness.run step से provider: opencode call करें।

Docker में OpenCode step
steps:
  - id: opencode_review
    action: harness.run
    container:
      image: dagu-opencode-runner:local
      pull_policy: never
      working_dir: /workspace
      volumes:
        - .:/workspace:ro
        - ${HOME}/.local/share/opencode:/root/.local/share/opencode:ro
    with:
      provider: opencode
      model: anthropic/claude-sonnet-4-5
      prompt: |
        Review this repository and summarize the highest-risk issues.

opencode-ai npm package से OpenCode install करता है।

Model calls से पहले Dagu के through opencode --version verify करता है।

Configured providers के लिए ~/.local/share/opencode/auth.json mount कर सकता है।

Provider-specific environment variables को container.env में भी use कर सकता है।

01

Runner image

OpenCode को runner image में install करें और build time पर binary verify करें। Empty entrypoint command control Dagu को देता है।

Dockerfile
FROM node:22-bookworm-slim

RUN apt-get update \
  && apt-get install -y --no-install-recommends ca-certificates git bash \
  && rm -rf /var/lib/apt/lists/*

RUN npm install -g opencode-ai
RUN opencode --version

WORKDIR /workspace
ENTRYPOINT []
CMD ["bash"]
02

Smoke test

Credentials mount करने से पहले shell provider चलाएं जो container के अंदर OpenCode version और binary path print करे।

Version check DAG
type: graph

harnesses:
  shell:
    binary: sh
    prefix_args:
      - -c
    prompt_mode: arg

steps:
  - id: opencode_version
    action: harness.run
    container:
      image: dagu-opencode-runner:local
      pull_policy: never
    with:
      provider: shell
      prompt: |
        set -eu
        opencode --version
        command -v opencode
03

Credentials

OpenCode provider login data को ~/.local/share/opencode/auth.json में store करता है और environment या project .env से provider keys भी पढ़ता है। चुने गए provider को जो चाहिए केवल वही mount या pass करें।

04

Model name

OpenCode model names provider/model form use करते हैं। Example anthropic/claude-sonnet-4-5 use करता है; इसे अपनी OpenCode provider configuration में available model से बदलें।