-
Notifications
You must be signed in to change notification settings - Fork 396
feat: add OpenCode CLI support in Docker #460
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add OpenCode CLI support in Docker #460
Conversation
- Install OpenCode CLI in Dockerfile alongside Claude and Cursor - Add automaker-opencode-config volume for persisting auth - Add OpenCode directory setup in docker-entrypoint.sh - Update docker-isolation.md with OpenCode documentation - Add OpenCode bind mount example to docker-compose.override.yml.example
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the 📝 WalkthroughWalkthroughInstalls the OpenCode CLI into the server image, exposes the user-local bin in interactive PATHs, adds named volumes and commented example mounts to persist OpenCode data/config, creates OpenCode config directories on container start with proper ownership/permissions, and documents mounting/troubleshooting steps. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary of ChangesHello @thesobercoder, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request introduces comprehensive support for the OpenCode CLI within Docker deployments. By integrating OpenCode, users can now leverage multi-provider AI model access directly from their Dockerized environment. The changes ensure proper installation, persistent configuration, and clear documentation, aligning OpenCode's setup with existing Claude and Cursor CLI patterns for a consistent user experience. Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request adds support for the OpenCode CLI to the Docker setup, which is a great feature enhancement. The changes are consistent with the existing setup for other CLIs like Claude and Cursor. My main feedback concerns an inconsistency with the OpenCode configuration directories. The docker-entrypoint.sh script correctly creates both ~/.local/share/opencode and ~/.config/opencode, but the Docker Compose files and documentation only account for persisting the former. This could lead to loss of configuration. I've provided suggestions to create a named volume for ~/.config/opencode and update the documentation accordingly. I've also included a minor refactoring suggestion for the entrypoint script to improve maintainability.
docker-compose.yml
Outdated
|
|
||
| # Persist OpenCode CLI configuration and authentication across container restarts | ||
| # This allows 'opencode auth login' authentication to persist between restarts | ||
| - automaker-opencode-config:/home/automaker/.local/share/opencode |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The docker-entrypoint.sh script also prepares a ~/.config/opencode directory, implying it's used for configuration. To ensure all OpenCode configuration is persisted, you should also mount a volume for that directory.
- automaker-opencode-config:/home/automaker/.local/share/opencode
- automaker-opencode-user-config:/home/automaker/.config/opencode
docker-compose.yml
Outdated
| automaker-opencode-config: | ||
| name: automaker-opencode-config | ||
| # Named volume for OpenCode CLI configuration and authentication | ||
| # Persists opencode auth login authentication across container restarts |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To support persisting the ~/.config/opencode directory, the new named volume automaker-opencode-user-config needs to be defined here.
automaker-opencode-config:
name: automaker-opencode-config
# Named volume for OpenCode CLI configuration and authentication
# Persists opencode auth login authentication across container restarts
automaker-opencode-user-config:
name: automaker-opencode-user-config
# Named volume for OpenCode CLI user-specific configuration
# Persists configuration stored in ~/.config/opencode| # OpenCode CLI - mount your ~/.local/share/opencode directory | ||
| # This shares your 'opencode auth login' session with the container | ||
| # - ~/.local/share/opencode:/home/automaker/.local/share/opencode |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The entrypoint script indicates that OpenCode uses both ~/.local/share/opencode and ~/.config/opencode. This example should be updated to show how to mount both directories for a complete host-to-container authentication sharing setup.
# OpenCode CLI - mount your config directories
# This shares your 'opencode auth login' session and config with the container
# - ~/.local/share/opencode:/home/automaker/.local/share/opencode
# - ~/.config/opencode:/home/automaker/.config/opencode
| # Ensure OpenCode CLI config directory exists with correct permissions | ||
| # OpenCode stores config and auth in ~/.local/share/opencode/ | ||
| if [ ! -d "/home/automaker/.local/share/opencode" ]; then | ||
| mkdir -p /home/automaker/.local/share/opencode | ||
| fi | ||
| chown -R automaker:automaker /home/automaker/.local/share/opencode | ||
| chmod -R 700 /home/automaker/.local/share/opencode | ||
|
|
||
| # OpenCode also uses ~/.config/opencode for configuration | ||
| if [ ! -d "/home/automaker/.config/opencode" ]; then | ||
| mkdir -p /home/automaker/.config/opencode | ||
| fi | ||
| chown -R automaker:automaker /home/automaker/.config/opencode | ||
| chmod -R 700 /home/automaker/.config/opencode |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This block can be simplified. The if [ ! -d ... ] checks are redundant because mkdir -p handles existing directories gracefully. You can remove the if statements to make the script cleaner.
| # Ensure OpenCode CLI config directory exists with correct permissions | |
| # OpenCode stores config and auth in ~/.local/share/opencode/ | |
| if [ ! -d "/home/automaker/.local/share/opencode" ]; then | |
| mkdir -p /home/automaker/.local/share/opencode | |
| fi | |
| chown -R automaker:automaker /home/automaker/.local/share/opencode | |
| chmod -R 700 /home/automaker/.local/share/opencode | |
| # OpenCode also uses ~/.config/opencode for configuration | |
| if [ ! -d "/home/automaker/.config/opencode" ]; then | |
| mkdir -p /home/automaker/.config/opencode | |
| fi | |
| chown -R automaker:automaker /home/automaker/.config/opencode | |
| chmod -R 700 /home/automaker/.config/opencode | |
| # Ensure OpenCode CLI config directories exist with correct permissions | |
| # OpenCode stores config and auth in ~/.local/share/opencode/ | |
| mkdir -p /home/automaker/.local/share/opencode | |
| chown -R automaker:automaker /home/automaker/.local/share/opencode | |
| chmod -R 700 /home/automaker/.local/share/opencode | |
| # OpenCode also uses ~/.config/opencode for configuration | |
| mkdir -p /home/automaker/.config/opencode | |
| chown -R automaker:automaker /home/automaker/.config/opencode | |
| chmod -R 700 /home/automaker/.config/opencode |
| ### OpenCode CLI | ||
|
|
||
| OpenCode stores its configuration and auth at `~/.local/share/opencode/`. To share your host authentication with the container: | ||
|
|
||
| ```yaml | ||
| # In docker-compose.override.yml | ||
| volumes: | ||
| - ~/.local/share/opencode:/home/automaker/.local/share/opencode | ||
| ``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The documentation should be updated to mention that OpenCode uses two directories (~/.local/share/opencode and ~/.config/opencode) and the example should reflect mounting both for complete configuration sharing.
| ### OpenCode CLI | |
| OpenCode stores its configuration and auth at `~/.local/share/opencode/`. To share your host authentication with the container: | |
| ```yaml | |
| # In docker-compose.override.yml | |
| volumes: | |
| - ~/.local/share/opencode:/home/automaker/.local/share/opencode | |
| ``` | |
| ### OpenCode CLI | |
| OpenCode stores its configuration and auth data across two directories: `~/.local/share/opencode/` and `~/.config/opencode/`. To share your host authentication with the container, mount both: | |
| ```yaml | |
| # In docker-compose.override.yml | |
| volumes: | |
| - ~/.local/share/opencode:/home/automaker/.local/share/opencode | |
| - ~/.config/opencode:/home/automaker/.config/opencode |
| volumes: | ||
| - ~/.claude:/home/automaker/.claude | ||
| - ~/.config/cursor:/home/automaker/.config/cursor | ||
| - ~/.local/share/opencode:/home/automaker/.local/share/opencode |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For consistency and to ensure all configurations are shared, this example for bind-mounting credential directories should also include ~/.config/opencode.
| - ~/.local/share/opencode:/home/automaker/.local/share/opencode | |
| - ~/.local/share/opencode:/home/automaker/.local/share/opencode | |
| - ~/.config/opencode:/home/automaker/.config/opencode |
| | Can't access web UI | Verify container is running with `docker ps \| grep automaker` | | ||
| | Need a fresh start | Run `docker-compose down && docker volume rm automaker-data && docker-compose up -d --build` | | ||
| | Cursor auth fails | Re-extract token with `./scripts/get-cursor-token.sh` - tokens expire periodically. Make sure you've run `cursor-agent login` on your host first. | | ||
| | OpenCode not detected | Mount `~/.local/share/opencode` to `/home/automaker/.local/share/opencode`. Make sure you've run `opencode auth login` on your host first. | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The troubleshooting advice should be updated to mention mounting both directories required by OpenCode for a complete setup.
| | OpenCode not detected | Mount `~/.local/share/opencode` to `/home/automaker/.local/share/opencode`. Make sure you've run `opencode auth login` on your host first. | | |
| | OpenCode not detected | Mount `~/.local/share/opencode` and `~/.config/opencode`. Make sure you've run `opencode auth login` on your host first. | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In @docker-entrypoint.sh:
- Around line 28-41: The entrypoint currently creates and sets permissions for
/home/automaker/.config/opencode (and /home/automaker/.local/share/opencode)
which makes config changes ephemeral; either add a Docker volume mount for
/home/automaker/.config/opencode (like the existing volume used for
/home/automaker/.local/share/opencode) so configuration persists across
container restarts, or remove the creation and permission lines for
/home/automaker/.config/opencode from docker-entrypoint.sh to avoid creating an
unmounted persistent-looking directory; update deployment/docker-compose or
Dockerfile volume definitions accordingly and keep the mkdir/chown/chmod for
/home/automaker/.local/share/opencode if that remains a mounted volume.
🧹 Nitpick comments (2)
docs/docker-isolation.md (1)
83-91: Section placement may confuse users.The OpenCode CLI section is under "CLI Authentication (macOS)" but OpenCode uses file-based storage (not Keychain), making it applicable to all platforms. Consider either:
- Moving this section to "CLI Authentication (Linux/Windows)" where bind mounts are discussed, or
- Adding a clarifying note that OpenCode uses file-based storage on all platforms.
📝 Suggested clarification
### OpenCode CLI +OpenCode uses file-based storage on all platforms (no Keychain integration). OpenCode stores its configuration and auth at `~/.local/share/opencode/`. To share your host authentication with the container:Dockerfile (1)
106-109: Consider renaming the profile script for clarity.The file
/etc/profile.d/cursor-cli.shnow provisions PATH for both Cursor and OpenCode CLIs. A more descriptive name likecli-tools.shorautomaker-cli.shwould better reflect its purpose.📝 Suggested rename
RUN mkdir -p /etc/profile.d && \ - echo 'export PATH="/home/automaker/.local/bin:$PATH"' > /etc/profile.d/cursor-cli.sh && \ - chmod +x /etc/profile.d/cursor-cli.sh + echo 'export PATH="/home/automaker/.local/bin:$PATH"' > /etc/profile.d/cli-tools.sh && \ + chmod +x /etc/profile.d/cli-tools.sh
📜 Review details
Configuration used: defaults
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (5)
Dockerfiledocker-compose.override.yml.exampledocker-compose.ymldocker-entrypoint.shdocs/docker-isolation.md
🔇 Additional comments (6)
docker-compose.override.yml.example (1)
19-21: LGTM!The OpenCode mount example follows the established pattern for Claude and Cursor CLI credential sharing.
docs/docker-isolation.md (2)
120-120: LGTM!The OpenCode mount is correctly added to the Linux/Windows bind mount example.
131-131: LGTM!Helpful troubleshooting entry for OpenCode detection issues.
docker-compose.yml (2)
81-83: LGTM!The OpenCode volume mount follows the established pattern for CLI configuration persistence.
109-112: LGTM!The named volume declaration is consistent with existing Claude and Cursor volume patterns.
Dockerfile (1)
99-104: The OpenCode CLI install URLhttps://opencode.ai/installis confirmed as the official installation method from opencode.ai's documentation. The installation approach is correct.
3de6d58 to
bb710ad
Compare
Adds OpenCode CLI support for Docker deployments, matching the existing Claude Code and Cursor CLI patterns.
Changes:
Summary by CodeRabbit
New Features
Documentation
✏️ Tip: You can customize this high-level summary in your review settings.