forked from anomalyco/opencode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
68 lines (51 loc) · 1.7 KB
/
Dockerfile
File metadata and controls
68 lines (51 loc) · 1.7 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
# OpenCode Server - AI Coding Agent
# Runs opencode in headless server mode for API access.
#
# Build: docker build -t ghcr.io/veriteknik/opencode-server:latest .
# Run: docker run -p 4000:4000 -e PORT=4000 ghcr.io/veriteknik/opencode-server:latest
FROM oven/bun:1.3-alpine AS builder
# Install git for build script
RUN apk add --no-cache git
WORKDIR /app
# Copy package files and lockfile
COPY package.json bun.lock ./
COPY packages ./packages
COPY sdks ./sdks
COPY patches ./patches
# Install dependencies
RUN bun install --frozen-lockfile
# Build the project for current platform only (--single)
WORKDIR /app/packages/opencode
# Set channel to avoid git branch detection
ENV OPENCODE_CHANNEL=latest
RUN bun run build --single
# Production image - use slim alpine
FROM alpine:3.20
WORKDIR /app
# Install runtime dependencies
RUN apk add --no-cache \
git \
ripgrep \
ca-certificates \
libstdc++ \
libgcc
# Copy built binary - the build creates opencode-linux-x64 directory
COPY --from=builder /app/packages/opencode/dist/opencode-linux-x64/bin/opencode /usr/local/bin/opencode
RUN chmod +x /usr/local/bin/opencode
# Create non-root user
RUN addgroup -g 1001 -S opencode && \
adduser -S opencode -u 1001 -G opencode && \
mkdir -p /workspace && \
chown -R opencode:opencode /workspace /app
USER opencode
# Default port for opencode serve
ENV PORT=4000 \
HOST=0.0.0.0
EXPOSE 4000
# Workspace volume
VOLUME ["/workspace"]
# Health check
HEALTHCHECK --interval=30s --timeout=5s --start-period=10s --retries=3 \
CMD wget --no-verbose --tries=1 --spider http://localhost:${PORT}/global/health || exit 1
# Run opencode serve
CMD ["opencode", "serve", "--port", "4000", "--hostname", "0.0.0.0"]