-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
61 lines (50 loc) · 2.04 KB
/
Dockerfile
File metadata and controls
61 lines (50 loc) · 2.04 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
# ============================================================
# Stage 1: Download opencode binary
# ============================================================
FROM debian:bookworm-slim AS downloader
ARG OPENCODE_VERSION=1.4.3
ARG TARGETARCH
RUN apt-get update && apt-get install -y --no-install-recommends \
curl \
ca-certificates \
&& rm -rf /var/lib/apt/lists/*
# Map Docker TARGETARCH to opencode release arch naming
RUN set -eux; \
case "${TARGETARCH}" in \
amd64) OC_ARCH="x64" ;; \
arm64) OC_ARCH="arm64" ;; \
*) echo "Unsupported architecture: ${TARGETARCH}" && exit 1 ;; \
esac; \
curl -fsSL \
"https://github.com/anomalyco/opencode/releases/download/v${OPENCODE_VERSION}/opencode-linux-${OC_ARCH}.tar.gz" \
-o /tmp/opencode.tar.gz; \
tar -xzf /tmp/opencode.tar.gz -C /tmp; \
chmod 755 /tmp/opencode
# ============================================================
# Stage 2: Runtime image
# ============================================================
FROM debian:bookworm-slim AS runtime
# Install runtime deps: git (many agents need it), curl, ca-certs, nodejs (for MCP npx tools)
RUN apt-get update && apt-get install -y --no-install-recommends \
ca-certificates \
curl \
git \
nodejs \
npm \
&& rm -rf /var/lib/apt/lists/*
# Create non-root user
RUN groupadd -g 1001 opencode \
&& useradd -u 1001 -g opencode -m -s /bin/bash opencode
# Copy binary from downloader stage
COPY --from=downloader --chown=opencode:opencode /tmp/opencode /usr/local/bin/opencode
# Copy opencode config (skills, commands, AGENTS.md, tui.json, opencode.json)
COPY --chown=opencode:opencode config/ /home/opencode/.config/opencode/
# /workspace is where the user mounts their project
# /home/opencode/.local/share/opencode is where opencode stores sessions
RUN mkdir -p /workspace \
&& mkdir -p /home/opencode/.local/share/opencode \
&& chown opencode:opencode /workspace \
&& chown -R opencode:opencode /home/opencode
USER opencode
WORKDIR /workspace
ENTRYPOINT ["opencode"]