Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .devcontainer/devcontainer-lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@
"resolved": "ghcr.io/synergy-shock/devcontainer-features/node@sha256:bcc652d2dd44d71e63a665e419369ad017d936f023fa41f35d7fe3d2a4fb9a48",
"integrity": "sha256:bcc652d2dd44d71e63a665e419369ad017d936f023fa41f35d7fe3d2a4fb9a48"
},
"ghcr.io/synergy-shock/devcontainer-features/opencode:1": {
"version": "1.0.0",
"resolved": "ghcr.io/synergy-shock/devcontainer-features/opencode@sha256:603e8087344006d0055152e7d70a7dcfcc6f610b011da87723c71763867fea2b",
"integrity": "sha256:603e8087344006d0055152e7d70a7dcfcc6f610b011da87723c71763867fea2b"
},
"ghcr.io/synergy-shock/devcontainer-features/rtk:0": {
"version": "0.1.0",
"resolved": "ghcr.io/synergy-shock/devcontainer-features/rtk@sha256:69779045064cdc8a6d92461949d15974d0e19bc78d0f2b791969d5d719f392d4",
Expand Down
5 changes: 4 additions & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,20 @@
"pnpmVersion": "latest",
},
"ghcr.io/synergy-shock/devcontainer-features/claude:2": {},
"ghcr.io/synergy-shock/devcontainer-features/opencode:1": {},
"ghcr.io/synergy-shock/devcontainer-features/rtk:0": {},
"ghcr.io/synergy-shock/devcontainer-features/gitbutler:0": {},
},
"mounts": [
"source=${localEnv:HOME}/.claude,target=/home/node/.claude,type=bind",
"source=${localEnv:HOME}/.claude.json,target=/home/node/.claude.json,type=bind",
"source=${localEnv:HOME}/.config/opencode,target=/home/node/.config/opencode,type=bind",
"source=${localEnv:HOME}/.local/share/opencode,target=/home/node/.local/share/opencode,type=bind",
"source=/Applications/1Password.app/Contents/MacOS/op-ssh-sign,target=/op-ssh-sign,type=bind,readonly",
"source=/run/host-services/ssh-auth.sock,target=/agent.sock,type=bind",
],
"customizations": {},
"runArgs": [],
"runArgs": ["--name", "devcontainer"],
"containerEnv": {
"SSH_AUTH_SOCK": "/agent.sock",
},
Expand Down
2 changes: 1 addition & 1 deletion src/opencode/devcontainer-feature.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"id": "opencode",
"version": "1.0.0",
"version": "1.0.1",
"name": "OpenCode",
"description": "Installs the OpenCode AI CLI.",
"documentationURL": "https://github.com/Synergy-Shock/devcontainer-features/tree/main/src/opencode",
Expand Down
22 changes: 20 additions & 2 deletions src/opencode/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,24 @@ fi

OPENCODE_VERSION="${VERSION:-latest}"

# ------------------------------------------------------------------
# Resolve the target user and home directory.
# The dev container CLI normally injects _REMOTE_USER / _REMOTE_USER_HOME,
# but they can be empty depending on the build context — derive sane
# fallbacks so chown/mkdir never run against an empty path.
# ------------------------------------------------------------------
if [ -z "${_REMOTE_USER}" ]; then
_REMOTE_USER="$(id -un 1000 2>/dev/null || echo root)"
fi

if [ -z "${_REMOTE_USER_HOME}" ]; then
_REMOTE_USER_HOME="$(getent passwd "${_REMOTE_USER}" | cut -d: -f6)"
fi

if [ -z "${_REMOTE_USER_HOME}" ]; then
_REMOTE_USER_HOME="$([ "${_REMOTE_USER}" = "root" ] && echo /root || echo "/home/${_REMOTE_USER}")"
fi

export DEBIAN_FRONTEND=noninteractive

apt-get update
Expand All @@ -34,8 +52,8 @@ opencode --version
echo "==> Adjusting permissions for ${_REMOTE_USER} user..."
chown -R "${_REMOTE_USER}:${_REMOTE_USER}" "${OPENCODE_INSTALL_HOME}" 2>/dev/null || true

echo "==> Pre-creating XDG directories for ${_REMOTE_USER} user..."
echo "==> Pre-creating XDG directories for ${_REMOTE_USER} user (home: ${_REMOTE_USER_HOME})..."
mkdir -p "${_REMOTE_USER_HOME}/.config" "${_REMOTE_USER_HOME}/.local"
chown -R "${_REMOTE_USER}:${_REMOTE_USER}" "${_REMOTE_USER_HOME}"
chown "${_REMOTE_USER}:${_REMOTE_USER}" "${_REMOTE_USER_HOME}" "${_REMOTE_USER_HOME}/.config" "${_REMOTE_USER_HOME}/.local" 2>/dev/null || true

echo "==> OpenCode feature installation complete!"