forked from agentserver/agentserver
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile.opencode
More file actions
64 lines (51 loc) · 2.67 KB
/
Dockerfile.opencode
File metadata and controls
64 lines (51 loc) · 2.67 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
FROM debian:trixie-slim
ARG BUN_RUNTIME_TRANSPILER_CACHE_PATH=0
ENV BUN_RUNTIME_TRANSPILER_CACHE_PATH=${BUN_RUNTIME_TRANSPILER_CACHE_PATH}
# Disable runtime fetch of models.dev — the binary already bundles a snapshot.
ENV OPENCODE_DISABLE_MODELS_FETCH=1
# Skip built-in plugin install/version checks — plugins are pre-installed below.
ENV OPENCODE_DISABLE_DEFAULT_PLUGINS=1
# Skip auto-update checks on startup.
ENV OPENCODE_DISABLE_AUTOUPDATE=1
RUN apt-get update && apt-get install -y --no-install-recommends \
ripgrep git ca-certificates curl unzip \
golang rustc cargo \
build-essential clang llvm \
nodejs npm python3 python3-pip python3-venv \
&& rm -rf /var/lib/apt/lists/* \
&& corepack enable && corepack prepare pnpm@latest --activate \
&& curl -fsSL https://bun.sh/install | bash && mv /root/.bun/bin/bun /usr/local/bin/bun \
&& curl -fsSL "https://dl.k8s.io/release/$(curl -fsSL https://dl.k8s.io/release/stable.txt)/bin/linux/$(dpkg --print-architecture)/kubectl" -o /usr/local/bin/kubectl \
&& chmod +x /usr/local/bin/kubectl
COPY opencode-bin /usr/local/bin/opencode
RUN useradd -m -d /home/agent agent
USER agent
# Pre-install @opencode-ai/plugin in ~/.config/opencode so Config.needsInstall()
# finds node_modules already present. We install @latest here; at runtime if the
# exact Installation.VERSION differs, installDependencies() runs a fast incremental
# bun install (or gracefully fails if the version is unpublished).
RUN mkdir -p /home/agent/.config/opencode && \
cd /home/agent/.config/opencode && \
echo '{"dependencies":{"@opencode-ai/plugin":"*"}}' > package.json && \
bun install
# Pre-install LSP servers into ~/.local/share/opencode/bin so first spawn doesn't
# download from the network. These match the `bun install` calls in lsp/server.ts:
# - typescript-language-server (+ typescript): for .ts/.js/.tsx/.jsx
# - pyright: for .py
# - bash-language-server: for .sh/.bash
# - yaml-language-server: for .yaml/.yml
# - dockerfile-language-server-nodejs: for Dockerfile
RUN mkdir -p /home/agent/.local/share/opencode/bin && \
cd /home/agent/.local/share/opencode/bin && \
echo '{"dependencies":{}}' > package.json && \
bun add typescript-language-server typescript pyright \
bash-language-server yaml-language-server \
dockerfile-language-server-nodejs
# Install gopls — lsp/server.ts runs `go install golang.org/x/tools/gopls@latest`.
ENV GOPATH=/home/agent/go
RUN go install golang.org/x/tools/gopls@latest
ENV PATH="/home/agent/go/bin:${PATH}"
RUN mkdir -p /home/agent/projects
WORKDIR /home/agent/projects
EXPOSE 4096
ENTRYPOINT ["opencode", "serve", "--hostname", "0.0.0.0", "--port", "4096"]