1+ # Build stage
2+ FROM docker.io/library/node:20-slim AS builder
3+
4+ # Install build dependencies
5+ RUN apt-get update && apt-get install -y --no-install-recommends \
6+ python3 \
7+ make \
8+ g++ \
9+ git \
10+ && apt-get clean \
11+ && rm -rf /var/lib/apt/lists/*
12+
13+ # Set up npm global package folder
14+ RUN mkdir -p /usr/local/share/npm-global
15+ ENV NPM_CONFIG_PREFIX=/usr/local/share/npm-global
16+ ENV PATH=$PATH:/usr/local/share/npm-global/bin
17+
18+ # Copy source code
19+ COPY . /home/node/app
20+ WORKDIR /home/node/app
21+
22+ # Install dependencies and build packages
23+ RUN npm ci \
24+ && npm run build --workspaces \
25+ && npm pack -w @qwen-code/qwen-code --pack-destination ./packages/cli/dist \
26+ && npm pack -w @qwen-code/qwen-code-core --pack-destination ./packages/core/dist
27+
28+ # Runtime stage
129FROM docker.io/library/node:20-slim
230
331ARG SANDBOX_NAME="qwen-code-sandbox"
432ARG CLI_VERSION_ARG
533ENV SANDBOX="$SANDBOX_NAME"
634ENV CLI_VERSION=$CLI_VERSION_ARG
735
8- # install minimal set of packages, then clean up
36+ # Install runtime dependencies
937RUN apt-get update && apt-get install -y --no-install-recommends \
1038 python3 \
11- make \
12- g++ \
1339 man-db \
1440 curl \
1541 dnsutils \
@@ -29,22 +55,19 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
2955 && apt-get clean \
3056 && rm -rf /var/lib/apt/lists/*
3157
32- # set up npm global package folder under /usr/local/share
33- # give it to non-root user node, already set up in base image
34- RUN mkdir -p /usr/local/share/npm-global \
35- && chown -R node:node /usr/local/share/npm-global
58+ # Set up npm global package folder
59+ RUN mkdir -p /usr/local/share/npm-global
3660ENV NPM_CONFIG_PREFIX=/usr/local/share/npm-global
3761ENV PATH=$PATH:/usr/local/share/npm-global/bin
3862
39- # switch to non-root user node
40- USER node
63+ # Copy built packages from builder stage
64+ COPY --from=builder /home/node/app/packages/cli/dist/*.tgz /tmp/
65+ COPY --from=builder /home/node/app/packages/core/dist/*.tgz /tmp/
4166
42- # install qwen-code and clean up
43- COPY packages/cli/dist/qwen-code-*.tgz /usr/local/share/npm-global/qwen-code.tgz
44- COPY packages/core/dist/qwen-code-qwen-code-core-*.tgz /usr/local/share/npm-global/qwen-code-core.tgz
45- RUN npm install -g /usr/local/share/npm-global/qwen-code.tgz /usr/local/share/npm-global/qwen-code-core.tgz \
67+ # Install built packages globally
68+ RUN npm install -g /tmp/*.tgz \
4669 && npm cache clean --force \
47- && rm -f /usr/local/share/npm-global/qwen-{code,code-core} .tgz
70+ && rm -rf /tmp/* .tgz
4871
49- # default entrypoint when none specified
50- CMD ["qwen" ]
72+ # Default entrypoint when none specified
73+ CMD ["qwen" ]
0 commit comments