Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.

next
cli 106 lines 3.86 KB
Raw
1 # Reusable Dockerfile for CLI e2e tests (debian runtime)
2 # Usage: docker build -f Dockerfile.cli --build-arg CLI_VERSION=0.1.24 --build-arg NODE_VERSION=22.23.5 --build-arg NODE_VERSION_DIGEST=sha256:e9f565d32859f0cbfb52125eafe8be39390f24dac302dc3cdf566e8ba3ab21ee -t test-name .
3
4 ARG NODE_VERSION
5 # Digest pin for the node:${NODE_VERSION}-slim base image; must come from toolchain-versions.json (no default on purpose so builds fail loudly instead of silently floating).
6 ARG NODE_VERSION_DIGEST
7 ARG CLI_VERSION=0.0.0
8 # Base images are digest-pinned for supply-chain integrity. ECR Public mirrors the
9 # Docker Official Images, so builds do not depend on Docker Hub availability, but
10 # its anonymous rate limit can still return 429 on shared runner IPs; CI mitigates
11 # that by retrying with backoff (see .github/actions/build-e2e-image).
12 ARG BASE_REGISTRY=public.ecr.aws/docker/library
13
14 # The toolchain stage depends only on the base image and mise.toml/mise.lock, so
15 # CI saves its layers to the GitHub Actions cache (see .github/actions/build-e2e-image).
16 FROM ${BASE_REGISTRY}/node:${NODE_VERSION}-slim@${NODE_VERSION_DIGEST} AS toolchain
17
18 ENV MISE_DATA_DIR="/mise"
19 ENV MISE_CACHE_DIR="/mise/cache"
20 ENV MISE_DISABLE_TOOLS="node,python,uv"
21 ENV MISE_TRUSTED_CONFIG_PATHS="/app"
22 ENV PATH="/mise/shims:$PATH"
23
24 WORKDIR /app
25
26 # Install system dependencies (mise needs curl + ca-certificates)
27 RUN apt-get update && \
28 apt-get install -y --no-install-recommends ca-certificates curl unzip && \
29 rm -rf /var/lib/apt/lists/*
30
31 # Install bun + pnpm via mise (versions pinned in mise.toml/mise.lock).
32 # mise is installed to /usr/local/bin; its shared cache and shims expose bun and
33 # pnpm while Node stays on the base image.
34 ENV XDG_CACHE_HOME="/mise/cache"
35 COPY .github/scripts/install-mise.sh ./.github/scripts/install-mise.sh
36 RUN MISE_INSTALL_PATH=/usr/local/bin/mise bash .github/scripts/install-mise.sh
37 COPY mise.toml mise.lock ./
38 RUN mise install && \
39 pnpm --version && \
40 bun --version
41
42 FROM toolchain AS builder
43
44 # Copy lockfile first for optimal layer caching
45 COPY pnpm-lock.yaml ./
46
47 # Copy workspace configuration files
48 COPY package.json \
49 pnpm-workspace.yaml \
50 .pnpmfile.cjs \
51 tsconfig.base.json \
52 tsdown.config.base.ts \
53 toolchain-versions.json \
54 ./
55
56 # pnpm applies these dependency patches during install
57 COPY patches/ ./patches/
58
59 # Copy all ts/packages (pre-built)
60 COPY ts/packages/ ./ts/packages/
61
62 # Install dependencies using pnpm
63 # Note: We intentionally don't use --mount=type=cache for the pnpm store here
64 # because it causes native binding issues across builds
65 RUN pnpm install --frozen-lockfile
66
67 # Build composio CLI binary
68 WORKDIR /app/ts/packages/cli
69 RUN bun build ./src/bin.ts \
70 --env DEBUG_OVERRIDE_* \
71 --compile \
72 --production \
73 --outfile /out/composio
74
75 # Build the `composio run` companion modules next to the binary. Without the
76 # run-helpers-runtime.mjs and generation-runtime.mjs wrappers every
77 # `composio run` treats the install as broken and enters the GitHub self-repair
78 # path.
79 RUN bun scripts/build-companion-modules.ts /out
80
81 # Copy CLI e2e tests last (changes frequently)
82 WORKDIR /app
83 COPY ts/e2e-tests/cli/ /app/ts/e2e-tests/cli/
84
85 # Pre-create Composio CLI cache directory to work around Bun issue #7967
86 RUN mkdir -p /tmp/.composio
87
88 # Runtime base pinned by digest, matching Dockerfile.install (same supply-chain rationale).
89 FROM ${BASE_REGISTRY}/debian:bookworm-slim@sha256:7c7b2c966bc9ee8cedfeef67e0e279108992c77681fa595db4a9d65c06ccc587
90
91 ENV PATH="/usr/local/bin:/bin"
92 ENV HOME="/tmp"
93
94 WORKDIR /app
95
96 # CLI binary plus the `composio run` companion modules, which must stay siblings
97 # of the executable (they are resolved from dirname(process.execPath)).
98 COPY --from=builder /out/ /usr/local/bin/
99
100 # CLI e2e tests
101 COPY --from=builder /app/ts/e2e-tests/cli/ /app/ts/e2e-tests/cli/
102
103 # CLI cache directory
104 COPY --from=builder /tmp/.composio /tmp/.composio
105
106 CMD ["/bin/sh"]