-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDockerfile
More file actions
83 lines (62 loc) · 3.38 KB
/
Dockerfile
File metadata and controls
83 lines (62 loc) · 3.38 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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# ─── Stage 1: Build UI ────────────────────────────────────────────────────────
FROM docker.io/oven/bun:1 AS ui-builder
WORKDIR /app
COPY package.json bun.lock bunfig.toml tsconfig.base.json tsconfig.json ./
COPY packages/hive-ui ./packages/hive-ui
# Stub other workspace packages so bun resolves the monorepo correctly
RUN mkdir -p packages/core packages/cli packages/mcp packages/skills packages/code-bridge && \
echo '{"name":"@hive/core","version":"0.0.0"}' > packages/core/package.json && \
echo '{"name":"@hive/cli","version":"0.0.0"}' > packages/cli/package.json && \
echo '{"name":"@hive/mcp","version":"0.0.0"}' > packages/mcp/package.json && \
echo '{"name":"@hive/skills","version":"0.0.0"}' > packages/skills/package.json && \
echo '{"name":"@hive/code-bridge","version":"0.0.0"}' > packages/code-bridge/package.json
RUN bun install
RUN cd packages/hive-ui && bun run build
# ─── Stage 2: Compile binary (targeting musl for Alpine) ──────────────────────
FROM docker.io/oven/bun:1 AS binary-builder
WORKDIR /app
# Copy manifests first so `bun install` is cached independently of source changes
COPY package.json bun.lock bunfig.toml tsconfig.base.json tsconfig.json ./
COPY packages/core/package.json ./packages/core/package.json
COPY packages/cli/package.json ./packages/cli/package.json
COPY packages/mcp/package.json ./packages/mcp/package.json
COPY packages/skills/package.json ./packages/skills/package.json
COPY packages/code-bridge/package.json ./packages/code-bridge/package.json
RUN bun install
# Copy source after install so dependency layer stays cached on code changes
COPY packages/core ./packages/core
COPY packages/cli ./packages/cli
COPY packages/mcp ./packages/mcp
COPY packages/skills ./packages/skills
COPY packages/code-bridge ./packages/code-bridge
# Set NODE_ENV=production so Bun inlines it correctly in the compiled binary
ENV NODE_ENV=production
# Compile standalone binary linked against musl (Alpine compatible)
RUN bun build --compile \
--target=bun-linux-x64-musl \
--outfile=/app/hive-server \
./packages/cli/src/index.ts
# ─── Stage 3: Minimal Alpine runtime ──────────────────────────────────────────
FROM docker.io/alpine:3.21
# ca-certificates for HTTPS, chromium for browser tools
RUN apk add --no-cache \
ca-certificates tzdata libgcc libstdc++ \
chromium nss freetype harfbuzz ttf-freefont
WORKDIR /app
# Copy compiled binary (self-contained, includes Bun runtime)
COPY --from=binary-builder /app/hive-server ./hive-server
# Copy bundled skills (.md files read at runtime via fs — not embedded in binary)
# Bun preserves original __dirname in compiled binary: packages/skills/src/bundled
COPY --from=binary-builder /app/packages/skills/src/bundled ./packages/skills/src/bundled
# Copy built UI
COPY --from=ui-builder /app/packages/hive-ui/dist ./ui
# Hive data directory — mount a volume here for persistence
VOLUME /root/.hive
EXPOSE 18790
ENV HIVE_HOST=0.0.0.0
ENV HIVE_PORT=18790
ENV HIVE_UI_DIR=/app/ui
ENV NODE_ENV=production
ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true
ENV PUPPETEER_EXECUTABLE_PATH=/usr/bin/chromium-browser
CMD ["/app/hive-server", "start", "--skip-check"]