Skip to content

Feat/reorganize dockerfiles - #4

Merged
yursds merged 6 commits into
mainfrom
feat/reorganize-dockerfiles
Apr 5, 2026
Merged

Feat/reorganize dockerfiles#4
yursds merged 6 commits into
mainfrom
feat/reorganize-dockerfiles

Conversation

@yursds

@yursds yursds commented Apr 5, 2026

Copy link
Copy Markdown
Owner

This pull request refactors the OpenCode Docker environment for both CPU and GPU images, focusing on improved user configuration, reproducibility, and security. The changes standardize the installation and configuration process, move all user-level installs to the non-root user, simplify config switching, and clarify agent and project conventions. It also updates documentation and tightens up Docker Compose settings for better control and security.

Container build and user management improvements:

  • All installations of Bun, OpenCode, and oh-my-openagent are now performed as the non-root user (hannya), ensuring correct permissions and environment setup. The PATH is updated to prioritize user binaries, and the HOME environment variable is set to the user's home directory. [1] [2]
  • Project and agent configs are copied into the user's .config/opencode/ directory during the build, and a script (switch-opencode-config) is installed for easy config switching. [1] [2]
  • The entrypoint script (entrypoint.sh) is rewritten to handle both root and non-root startup, ensure proper ownership of the home directory, and activate the requested OpenCode config on container start.

Configuration and conventions:

  • All hardcoded values are removed in favor of environment variables, config files, or constants. This is enforced in both the documentation and the global agent rules. [1] [2]
  • The config switching script is simplified and now uses consistent file naming (oh-my-openagent-*.json). Usage messages are clarified, and the default config is restored from a new default file.

Docker Compose and security enhancements:

  • The Compose files now explicitly set the user to 1000:1000, pass through MYUID and MYGID, and default to the free OpenCode config. [1] [2] [3] [4]
  • Security options are updated: no-new-privileges is set to false, and a more granular set of capabilities is dropped/added to balance functionality and security. [1] [2]

Documentation updates:

  • A new AGENTS.md provides a clear overview of the repo, conventions, commands, and strict agent/Git rules for working in this environment.

Summary of most important changes:

User environment and installation:

  • All tool installations (Bun, OpenCode, oh-my-openagent) and config management now run as the non-root user, ensuring correct permissions and a reproducible user environment. [1] [2]
  • Entrypoint script rewritten for robust user handling and dynamic config activation on container start.

Configuration and conventions:

  • Hardcoded values are eliminated in favor of config files and environment variables, enforced in both code and documentation. [1] [2]
  • Config switching script (switch-opencode-config.sh) is simplified and standardized for easier use and maintenance.

Docker Compose and security:

  • Compose files now set explicit user/group IDs, pass through relevant environment variables, and use a more secure and functional set of Linux capabilities. [1] [2] [3] [4]

Documentation:

  • Added a comprehensive AGENTS.md outlining usage, conventions, and agent rules for the environment.

yursds added 6 commits April 5, 2026 11:10
…ilities

Remove USER directive from both Dockerfiles and set user: 1000:1000 in docker-compose.yml. Replace cap_drop: ALL with targeted drops and add capabilities needed for sudo (SETUID, SETGID, DAC_OVERRIDE, FOWNER). Set no-new-privileges:false to allow privilege escalation.
Add UID check to handle both compose user mode (1000:1000) and root mode. Root path performs chown and su -l to switch user. Non-root path skips chown and executes command directly.
@yursds
yursds merged commit 7d58e61 into main Apr 5, 2026
@yursds
yursds deleted the feat/reorganize-dockerfiles branch April 5, 2026 22:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant