Skip to content

Commit e6b80cd

Browse files
committed
feat(opencode): add gemini auth bootstrap
Add opencode configuration and npm dependency so the gemini auth plugin is installed with the feature by default. Require the node feature and run the on-create hook to guarantee npm is present and emit setup status as the container initializes. Signed-off-by: Svetlin Ralchev <[email protected]>
1 parent 9a83693 commit e6b80cd

File tree

4 files changed

+37
-9
lines changed

4 files changed

+37
-9
lines changed

src/opencode/devcontainer-feature.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
}
1313
},
1414
"installsAfter": [
15-
"ghcr.io/devcontainers/features/common-utils"
16-
]
15+
"ghcr.io/devcontainers/features/common-utils",
16+
"ghcr.io/devcontainers/features/node"
17+
],
18+
"onCreateCommand": "/etc/opencode/hooks/on-create.sh"
1719
}

src/opencode/files/opencode.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"$schema": "https://opencode.ai/config.json",
3+
"plugin": [
4+
"opencode-gemini-auth"
5+
]
6+
}

src/opencode/hooks/on-create.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/bin/sh
2+
set -e
3+
4+
CONFIG_PATH="$HOME/.config/opencode"
5+
# Make sure that the configuration directory exists
6+
mkdir -p "$CONFIG_PATH"
7+
# Copy the system-wide configuration as a user configuration
8+
cp /etc/opencode/opencode.json "$CONFIG_PATH/opencode.json"
9+
# Make sure that user has correct permissions
10+
chown -R "$(id -u):$(id -g)" "${CONFIG_PATH}"

src/opencode/install.sh

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,17 @@
22
set -e
33

44
apt_get_update() {
5-
if [ "$(find /var/lib/apt/lists/* | wc -l)" = "0" ]; then
6-
echo "Running apt-get update..."
7-
apt-get update -y
8-
fi
5+
if [ "$(find /var/lib/apt/lists/* | wc -l)" = "0" ]; then
6+
echo "Running apt-get update..."
7+
apt-get update -y
8+
fi
99
}
1010

1111
# Checks if packages are installed and installs them if not
1212
apt_get() {
13-
if ! dpkg -s "$@" >/dev/null 2>&1; then
14-
apt-get -y install --no-install-recommends "$@"
15-
fi
13+
if ! dpkg -s "$@" >/dev/null 2>&1; then
14+
apt-get -y install --no-install-recommends "$@"
15+
fi
1616
}
1717

1818
apt_get_update
@@ -26,3 +26,13 @@ curl -fsSL https://opencode.ai/install | bash
2626

2727
# Make opencode available for everybody
2828
mv "$HOME/.opencode/bin/opencode" /usr/local/bin/opencode
29+
30+
# Create the global config
31+
mkdir -p /etc/opencode/hooks
32+
33+
# Copy the configuration
34+
cp -R files/* /etc/opencode
35+
cp -R hooks/* /etc/opencode/hooks
36+
37+
# Install opencode-gemini-auth
38+
npm install -g opencode-gemini-auth

0 commit comments

Comments
 (0)