-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile.opencode
More file actions
52 lines (45 loc) · 2.47 KB
/
Dockerfile.opencode
File metadata and controls
52 lines (45 loc) · 2.47 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
# OpenCode server image, built locally from the public npm package.
#
# Replaces the previous `image: ghcr.io/sst/opencode:latest` reference,
# which was inherited from the upstream compose file but does not exist
# at that path on the public registry. Building from npm gives us a
# predictable image with no registry-auth surprises.
# node:22-slim is Debian-based (glibc). The opencode-ai npm package ships
# platform-specific binaries via optionalDependencies — those binaries are
# built against glibc, so on Alpine (musl) none of the optionals match and
# the wrapper crashes with `spawnSync .../bin/.opencode ENOENT`. Slim with
# glibc resolves that.
FROM node:22-slim
# Tools OpenCode frequently shells out to while serving a workspace.
# `jq` is used by the entrypoint to merge our managed MCP entry into a
# user-provided opencode.json without clobbering their other servers.
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
git openssh-client bash curl ca-certificates jq \
&& rm -rf /var/lib/apt/lists/*
# Install the OpenCode CLI globally into the system prefix (/usr/local).
# This intentionally happens BEFORE we change npm's prefix so opencode-ai
# stays in the image layer and gets refreshed on each `--build`. The
# user-installed packages further down go to a separate prefix backed
# by a volume.
RUN npm install -g opencode-ai@latest
# Switch npm's global prefix to a path that is mounted as a volume in
# docker-compose.yml (opencode-npm). Anything the user installs via
# `npm install -g <pkg>` from now on lands in /root/.npm-global and
# survives image rebuilds. /root/.local covers `pip install --user`.
# Both directories are added to PATH so installed binaries Just Work.
RUN mkdir -p /workspace /root/.config/opencode /root/.npm-global /root/.local/bin \
&& npm config set prefix /root/.npm-global
ENV PATH="/root/.npm-global/bin:/root/.local/bin:${PATH}"
WORKDIR /workspace
# Entrypoint generates ~/.config/opencode/mcp.json from env vars on
# container start so OpenCode discovers the bot's memory MCP server
# automatically.
COPY docker/opencode-entrypoint.sh /usr/local/bin/opencode-entrypoint.sh
RUN chmod +x /usr/local/bin/opencode-entrypoint.sh
EXPOSE 4096
# Bind to 0.0.0.0 so the bot container can reach the server through the
# compose network. The bot reads OPENCODE_API_URL=http://opencode:4096
# from .env and connects there.
ENTRYPOINT ["/usr/local/bin/opencode-entrypoint.sh"]
CMD ["opencode", "serve", "--hostname", "0.0.0.0", "--port", "4096"]