Skip to content

Commit 85abeec

Browse files
committed
feat(docker): ✨ add Dockerfile for OpenCode environment
1 parent 26a1ab9 commit 85abeec

1 file changed

Lines changed: 138 additions & 0 deletions

File tree

Dockerfile

Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
# hadolint ignore=DL3007
2+
FROM oven/bun:latest
3+
4+
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
5+
6+
USER root
7+
8+
ENV DEBIAN_FRONTEND=noninteractive
9+
10+
# hadolint ignore=DL3008,DL3015,SC2116
11+
RUN <<'FOE'
12+
13+
apt-get update
14+
apt-get install \
15+
sudo \
16+
curl \
17+
git \
18+
libatomic1 \
19+
-y
20+
21+
apt-get install make gpg -y --no-install-recommends
22+
23+
rm -rf /var/lib/apt/lists/* /var/cache/apt
24+
25+
# PREPEND the script loader to /etc/bash.bashrc (before the early return for non-interactive shells)
26+
# The default /etc/bash.bashrc has "[ -z "${PS1-}" ] && return" which exits early for non-interactive shells
27+
{
28+
cat <<-'HEADER'
29+
# script loader for /etc/bash_profile.d (prepended for non-interactive shell support)
30+
if [ -d /etc/bash_profile.d ]; then
31+
shopt -s nullglob
32+
while IFS= read -r _script; do
33+
[ -f "$_script" ] && [ -r "$_script" ] && . "$_script"
34+
done < <(printf '%s\n' /etc/bash_profile.d/[0-9]* | sort -V)
35+
for _script in /etc/bash_profile.d/[!0-9]*; do
36+
[ -f "$_script" ] && [ -r "$_script" ] && . "$_script"
37+
done
38+
unset _script
39+
shopt -u nullglob
40+
fi
41+
42+
HEADER
43+
cat /etc/bash.bashrc
44+
} > /etc/bash.bashrc.new
45+
mv /etc/bash.bashrc.new /etc/bash.bashrc
46+
47+
usermod --shell /bin/bash bun
48+
49+
curl https://mise.run | MISE_INSTALL_PATH=/usr/local/bin/mise sh
50+
51+
# Create the bash_profile.d directory and mise script
52+
mkdir /etc/bash_profile.d
53+
cat >/etc/bash_profile.d/mise <<-'EOF'
54+
export PATH=/usr/local/bun/bin:$HOME/.local/bin:$PATH
55+
# Use appropriate mise activation based on shell type
56+
if [[ $- == *i* ]]; then
57+
# Interactive shell: use activate which sets up PROMPT_COMMAND hooks
58+
eval "$(mise activate)"
59+
else
60+
# Non-interactive shell: use hook-env with --force to skip early exit check
61+
eval "$(mise hook-env -C $HOME -s bash --force)"
62+
fi
63+
EOF
64+
65+
chown -Rh bun:bun "$(echo ~bun)"
66+
67+
FOE
68+
69+
COPY --chmod=0555 entrypoint.sh /entrypoint.sh
70+
71+
ARG OPENCODE_VERSION=latest
72+
ENV OPENCODE_CONFIG_DIR=/etc/opencode
73+
74+
# hadolint ignore=DL3003,SC2164
75+
RUN <<'FOE'
76+
77+
export BUN_INSTALL=/usr/local/bun
78+
export PROVIDER_DIR=/usr/local/provider
79+
80+
mkdir -p "${BUN_INSTALL}" "${OPENCODE_CONFIG_DIR}" "${PROVIDER_DIR}"
81+
82+
bun install -g "opencode-ai@${OPENCODE_VERSION}" || exit 1
83+
84+
###
85+
# providers
86+
#
87+
pushd /tmp
88+
89+
bun install "github:ophiosdev/azure-foundry-provider" || exit 1
90+
cd node_modules/azure-foundry-provider || exit 1
91+
bun build --outdir=dist src/index.ts || exit 1
92+
mv dist "${PROVIDER_DIR}/azure-foundry-provider"
93+
rm -rf /tmp/*
94+
95+
popd || exit 1
96+
97+
EOF
98+
99+
rm -rf /root/.bun
100+
101+
FOE
102+
103+
USER bun
104+
105+
RUN mise use -g --silent python@3.12.12 go@1.24 ripgrep uv
106+
107+
# hadolint ignore=DL3045
108+
COPY --chown=bun:bun git-export.py git-export.py
109+
110+
ENV XDG_CONFIG_HOME=/home/bun/.config
111+
112+
RUN <<'FOE'
113+
source /etc/bash.bashrc
114+
115+
skills_dir="${XDG_CONFIG_HOME}/opencode/skills"
116+
mkdir -p "${skills_dir}"
117+
118+
skill_name="humanizer"
119+
mkdir -p "${skills_dir}/${skill_name}"
120+
curl -L 'https://raw.githubusercontent.com/blader/humanizer/refs/heads/main/SKILL.md' -o "${skills_dir}/${skill_name}/SKILL.md"
121+
122+
uv pip install --system "aleph-rlm[mcp]"
123+
skill_name="aleph"
124+
mkdir -p "${skills_dir}/${skill_name}"
125+
curl -L 'https://raw.githubusercontent.com/Hmbown/aleph/refs/heads/main/docs/prompts/aleph.md' -o "${skills_dir}/${skill_name}/SKILL.md"
126+
127+
skill_name="changelog"
128+
python git-export.py https://github.com/sickn33/antigravity-awesome-skills/skills/changelog-automation "${skills_dir}/${skill_name}" --force
129+
130+
rm -f git-export.py
131+
FOE
132+
133+
# Set BASH_ENV so non-interactive bash shells (spawned by OpenCode CLI) source /etc/bash.bashrc
134+
# This ensures mise activation and PATH are available in shell commands
135+
ENV BASH_ENV=/etc/bash.bashrc
136+
ENV SHELL=/bin/bash
137+
138+
ENTRYPOINT [ "/entrypoint.sh" ]

0 commit comments

Comments
 (0)