-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathDockerfile.cli
More file actions
64 lines (56 loc) · 2.26 KB
/
Copy pathDockerfile.cli
File metadata and controls
64 lines (56 loc) · 2.26 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
# `tb` 完整 CLI 的独立 Bun 二进制镜像。
#
# 本地构建:
# docker build -f Dockerfile.cli -t tb-cli:local .
# docker run --rm tb-cli:local --version
#
# 多架构发布:
# docker buildx build --platform linux/amd64,linux/arm64 \
# -f Dockerfile.cli -t ghcr.io/tokenrollai/tool-bridge-cli:0.14.0 --push .
ARG BUN_VERSION=1.3.14
ARG TB_VERSION=0.14.0
FROM --platform=$BUILDPLATFORM oven/bun:${BUN_VERSION}-alpine AS bun
FROM --platform=$BUILDPLATFORM node:22-alpine AS build
WORKDIR /repo
ARG TB_VERSION
COPY --from=bun /usr/local/bin/bun /usr/local/bin/bun
RUN corepack enable
COPY package.json pnpm-lock.yaml pnpm-workspace.yaml tsconfig.base.json ./
COPY packages ./packages
# CLI 现在通过 tsup source alias 内联 SDK client/device/store;必须先用与 npm
# 产物相同的 tsup 路径构建,再让 Bun 编译单文件 dist。只安装该闭包,
# 不拉 Dashboard/Workers/server 等无关工作区。
RUN pnpm install --frozen-lockfile --ignore-scripts \
--filter @tool-bridge/cli --filter @tool-bridge/core --filter @tool-bridge/sdk \
&& pnpm --filter @tool-bridge/cli build
ARG TARGETARCH
RUN test "$(node -p "require('./packages/cli/package.json').version")" = "$TB_VERSION" \
&& case "$TARGETARCH" in \
amd64) bun_target=bun-linux-x64-musl ;; \
arm64) bun_target=bun-linux-arm64-musl ;; \
*) echo "unsupported TARGETARCH: $TARGETARCH" >&2; exit 1 ;; \
esac \
&& mkdir -p /out \
&& bun build packages/cli/dist/index.js \
--compile \
--minify \
--target="$bun_target" \
--outfile=/out/tb
FROM alpine:3.22
ARG TB_VERSION
LABEL org.opencontainers.image.title="Tool Bridge CLI" \
org.opencontainers.image.description="Complete tb CLI compiled as a standalone Bun executable" \
org.opencontainers.image.version="$TB_VERSION" \
org.opencontainers.image.source="https://github.com/TokenRollAI/tool-bridge"
RUN apk add --no-cache ca-certificates libgcc libstdc++ \
&& addgroup -S -g 10001 tb \
&& adduser -S -D -u 10001 -G tb -h /home/tb tb \
&& mkdir -p /home/tb/.config \
&& chown tb:tb /home/tb/.config
COPY --from=build --chown=tb:tb /out/tb /usr/local/bin/tb
ENV HOME=/home/tb
USER tb
WORKDIR /home/tb
STOPSIGNAL SIGTERM
ENTRYPOINT ["/usr/local/bin/tb"]
CMD ["--help"]