-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
208 lines (165 loc) · 5.46 KB
/
Dockerfile
File metadata and controls
208 lines (165 loc) · 5.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
# hadolint ignore=DL3007
FROM oven/bun:latest
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
USER root
ENV DEBIAN_FRONTEND=noninteractive
# hadolint ignore=DL3008,DL3015,SC2116
RUN <<'FOE'
apt-get update
apt-get install \
sudo \
curl \
git \
libatomic1 \
-y
apt-get install make gpg -y --no-install-recommends
rm -rf /var/lib/apt/lists/* /var/cache/apt
# PREPEND the script loader to /etc/bash.bashrc (before the early return for non-interactive shells)
# The default /etc/bash.bashrc has "[ -z "${PS1-}" ] && return" which exits early for non-interactive shells
{
cat <<-'HEADER'
# script loader for /etc/bash_profile.d (prepended for non-interactive shell support)
if [ -d /etc/bash_profile.d ]; then
shopt -s nullglob
while IFS= read -r _script; do
[ -f "$_script" ] && [ -r "$_script" ] && . "$_script"
done < <(printf '%s\n' /etc/bash_profile.d/[0-9]* | sort -V)
for _script in /etc/bash_profile.d/[!0-9]*; do
[ -f "$_script" ] && [ -r "$_script" ] && . "$_script"
done
unset _script
shopt -u nullglob
fi
HEADER
cat /etc/bash.bashrc
} > /etc/bash.bashrc.new
mv /etc/bash.bashrc.new /etc/bash.bashrc
usermod --shell /bin/bash bun
curl https://mise.run | MISE_INSTALL_PATH=/usr/local/bin/mise sh
# Create the bash_profile.d directory and mise script
mkdir /etc/bash_profile.d
cat >/etc/bash_profile.d/mise <<-'EOF'
export PATH=/usr/local/bun/bin:$HOME/.local/bin:$PATH
# Use appropriate mise activation based on shell type
if [[ $- == *i* ]]; then
# Interactive shell: use activate which sets up PROMPT_COMMAND hooks
eval "$(mise activate)"
else
# Non-interactive shell: use hook-env with --force to skip early exit check
eval "$(mise hook-env -C $HOME -s bash --force)"
fi
EOF
FOE
COPY --chmod=0555 entrypoint.sh /entrypoint.sh
ARG OPENCODE_VERSION=latest
ARG AZURE_FOUNDRY_PROVIDER_VERSION=0.2.0
ARG ENGRAM_VERSION=v1.9.1
ENV OPENCODE_CONFIG_DIR=/etc/opencode
ENV OPENCODE_EXPERIMENTAL=1
ENV ENGRAM_DATA_DIR=/home/bun/.local/share/opencode/engram
# hadolint ignore=DL3003,SC2164
RUN <<'FOE'
export BUN_INSTALL=/usr/local/bun
export PROVIDER_DIR=/usr/local/provider
export OPENCODE_PLUGINS_DIR="${OPENCODE_CONFIG_DIR}/plugins"
mkdir -p "${BUN_INSTALL}" "${OPENCODE_CONFIG_DIR}" "${OPENCODE_PLUGINS_DIR}" "${PROVIDER_DIR}"
chmod 0777 "${OPENCODE_CONFIG_DIR}"
bun install -g "opencode-ai@${OPENCODE_VERSION}" || exit 1
###
# providers
#
pushd /tmp
bun install "github:ophiosdev/azure-foundry-provider#v${AZURE_FOUNDRY_PROVIDER_VERSION}" || exit 1
cd node_modules/azure-foundry-provider || exit 1
bun build --outdir=dist src/index.ts || exit 1
mv dist "${PROVIDER_DIR}/azure-foundry-provider"
rm -rf /tmp/*
popd || exit 1
engram_version="${ENGRAM_VERSION#v}"
engram_archive="engram_${engram_version}_linux_amd64.tar.gz"
engram_url="https://github.com/Gentleman-Programming/engram/releases/download/${ENGRAM_VERSION}/${engram_archive}"
curl -fsSL "${engram_url}" | tar -C /usr/local/bin -xvzf - engram
curl -fsSL 'https://raw.githubusercontent.com/Gentleman-Programming/engram/refs/tags/${ENGRAM_VERSION}/plugin/opencode/engram.ts' -o "${OPENCODE_PLUGINS_DIR}/engram.ts"
rm -rf /root/.bun
chown -Rh bun:bun "$(echo ~bun)"
FOE
USER bun:bun
RUN mise use -g --silent python@3.12.12 go@1.24 ripgrep uv
# hadolint ignore=DL3045
COPY --chown=bun:bun git-export.py git-export.py
RUN <<'FOE'
source /etc/bash.bashrc
skills_dir="${OPENCODE_CONFIG_DIR}/skills"
mkdir -p "${skills_dir}"
skill_name="humanizer"
mkdir -p "${skills_dir}/${skill_name}"
curl -L 'https://raw.githubusercontent.com/blader/humanizer/refs/heads/main/SKILL.md' -o "${skills_dir}/${skill_name}/SKILL.md"
uv pip install --system "aleph-rlm[mcp]"
skill_name="aleph"
mkdir -p "${skills_dir}/${skill_name}"
curl -L 'https://raw.githubusercontent.com/Hmbown/aleph/refs/heads/main/docs/prompts/aleph.md' -o "${skills_dir}/${skill_name}/SKILL.md"
skill_name="changelog"
python git-export.py https://github.com/sickn33/antigravity-awesome-skills/skills/changelog-automation "${skills_dir}/${skill_name}" --force
uv pip install --system jcodemunch-mcp
rm -f git-export.py
cat >"${OPENCODE_CONFIG_DIR}/opencode.json" <<-'EOF'
{
"$schema": "https://opencode.ai/config.json",
"plugin": [
"engram"
],
"mcp": {
"engram": {
"type": "local",
"command": [
"engram",
"mcp",
"--tools=agent"
],
"enabled": false
},
"sequential-thinking": {
"type": "local",
"command": [
"bun",
"x",
"@modelcontextprotocol/server-sequential-thinking"
],
"enabled": false
},
"aleph": {
"type": "local",
"command": [
"aleph",
"--enable-actions",
"--workspace-mode",
"any",
"--tool-docs",
"concise"
],
"enabled": false
},
"msdocs": {
"type": "remote",
"url": "https://learn.microsoft.com/api/mcp",
"enabled": false
},
"jcodemunch": {
"type": "local",
"command": [
"jcodemunch-mcp", "--log-level", "DEBUG", "--log-file", "/home/bun/.local/share/opencode/log/jcodemunch.log"
],
"environment": {
"JCODEMUNCH_SHARE_SAVINGS": "0"
},
"enabled": false
}
}
}
EOF
FOE
# Set BASH_ENV so non-interactive bash shells (spawned by OpenCode CLI) source /etc/bash.bashrc
# This ensures mise activation and PATH are available in shell commands
ENV BASH_ENV=/etc/bash.bashrc
ENV SHELL=/bin/bash
ENTRYPOINT [ "/entrypoint.sh" ]