2026-05-05 01:21:06 +05:30
|
|
|
# ---- Stage 1: Builder ----
|
|
|
|
|
FROM docker.io/library/node:20-slim AS builder
|
|
|
|
|
|
|
|
|
|
# Install git (needed by generate-git-commit-info.js script)
|
|
|
|
|
RUN apt-get update && apt-get install -y --no-install-recommends git \
|
|
|
|
|
&& apt-get clean && rm -rf /var/lib/apt/lists/*
|
|
|
|
|
|
|
|
|
|
WORKDIR /build
|
|
|
|
|
|
|
|
|
|
# Copy only package.json files first for better layer caching
|
|
|
|
|
# Dependencies only re-install when package files change, not source files
|
|
|
|
|
COPY package*.json ./
|
|
|
|
|
COPY packages/cli/package*.json ./packages/cli/
|
|
|
|
|
COPY packages/core/package*.json ./packages/core/
|
|
|
|
|
COPY packages/vscode-ide-companion/package*.json ./packages/vscode-ide-companion/
|
|
|
|
|
COPY packages/vscode-ide-companion/scripts/ ./packages/vscode-ide-companion/scripts/
|
|
|
|
|
COPY packages/devtools/package*.json ./packages/devtools/
|
|
|
|
|
COPY packages/sdk/package*.json ./packages/sdk/
|
|
|
|
|
COPY packages/test-utils/package*.json ./packages/test-utils/
|
|
|
|
|
COPY packages/a2a-server/package*.json ./packages/a2a-server/
|
|
|
|
|
|
|
|
|
|
# Use npm ci for consistent, reliable builds (respects package-lock.json)
|
|
|
|
|
RUN HUSKY=0 npm ci --ignore-scripts
|
|
|
|
|
|
|
|
|
|
# Now copy the rest of the source (after install for better caching)
|
|
|
|
|
COPY packages/ ./packages/
|
|
|
|
|
COPY tsconfig*.json ./
|
|
|
|
|
COPY eslint.config.js ./
|
|
|
|
|
COPY scripts/ ./scripts/
|
|
|
|
|
COPY esbuild.config.js ./
|
|
|
|
|
|
|
|
|
|
# Pass git commit hash as build arg instead of copying entire .git directory
|
|
|
|
|
ARG GIT_COMMIT=unknown
|
|
|
|
|
ENV GIT_COMMIT=$GIT_COMMIT
|
|
|
|
|
|
|
|
|
|
# Build and pack artifacts
|
|
|
|
|
RUN HUSKY=0 npm run build && \
|
|
|
|
|
npm pack -w packages/core --pack-destination packages/core/dist/ && \
|
|
|
|
|
npm pack -w packages/cli --pack-destination packages/cli/dist/
|
|
|
|
|
|
|
|
|
|
# ---- Stage 2: Runtime ----
|
2025-10-17 07:48:29 -07:00
|
|
|
FROM docker.io/library/node:20-slim
|
2025-04-20 08:22:17 -07:00
|
|
|
|
2025-05-30 18:02:27 +00:00
|
|
|
ARG SANDBOX_NAME="gemini-cli-sandbox"
|
2025-06-16 01:13:39 -05:00
|
|
|
ARG CLI_VERSION_ARG
|
2025-05-30 18:02:27 +00:00
|
|
|
ENV SANDBOX="$SANDBOX_NAME"
|
2025-06-16 01:13:39 -05:00
|
|
|
ENV CLI_VERSION=$CLI_VERSION_ARG
|
2025-05-29 22:16:39 +00:00
|
|
|
|
2025-04-20 08:22:17 -07:00
|
|
|
# install minimal set of packages, then clean up
|
|
|
|
|
RUN apt-get update && apt-get install -y --no-install-recommends \
|
2025-06-08 01:04:20 -04:00
|
|
|
python3 \
|
|
|
|
|
make \
|
|
|
|
|
g++ \
|
2025-04-20 08:22:17 -07:00
|
|
|
man-db \
|
|
|
|
|
curl \
|
|
|
|
|
dnsutils \
|
|
|
|
|
less \
|
|
|
|
|
jq \
|
|
|
|
|
bc \
|
|
|
|
|
gh \
|
|
|
|
|
git \
|
|
|
|
|
unzip \
|
|
|
|
|
rsync \
|
|
|
|
|
ripgrep \
|
|
|
|
|
procps \
|
|
|
|
|
psmisc \
|
|
|
|
|
lsof \
|
2025-04-28 18:40:24 -07:00
|
|
|
socat \
|
2025-06-10 08:58:37 -07:00
|
|
|
ca-certificates \
|
2025-04-20 08:22:17 -07:00
|
|
|
&& apt-get clean \
|
|
|
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
|
|
|
|
|
|
# set up npm global package folder under /usr/local/share
|
|
|
|
|
# give it to non-root user node, already set up in base image
|
|
|
|
|
RUN mkdir -p /usr/local/share/npm-global \
|
|
|
|
|
&& chown -R node:node /usr/local/share/npm-global
|
|
|
|
|
ENV NPM_CONFIG_PREFIX=/usr/local/share/npm-global
|
|
|
|
|
ENV PATH=$PATH:/usr/local/share/npm-global/bin
|
|
|
|
|
|
2025-10-17 07:48:29 -07:00
|
|
|
# switch to non-root user node
|
2025-04-20 08:22:17 -07:00
|
|
|
USER node
|
|
|
|
|
|
2025-10-17 07:48:29 -07:00
|
|
|
# install gemini-cli and clean up
|
2026-04-24 14:29:38 -07:00
|
|
|
COPY --chown=node:node packages/cli/dist/google-gemini-cli-*.tgz /tmp/gemini-cli.tgz
|
|
|
|
|
COPY --chown=node:node packages/core/dist/google-gemini-cli-core-*.tgz /tmp/gemini-core.tgz
|
2026-02-24 02:32:42 +05:30
|
|
|
RUN npm install -g /tmp/gemini-core.tgz \
|
|
|
|
|
&& npm install -g /tmp/gemini-cli.tgz \
|
|
|
|
|
&& node -e "const fs=require('node:fs'); JSON.parse(fs.readFileSync('/usr/local/share/npm-global/lib/node_modules/@google/gemini-cli/package.json','utf8')); JSON.parse(fs.readFileSync('/usr/local/share/npm-global/lib/node_modules/@google/gemini-cli-core/package.json','utf8'));" \
|
|
|
|
|
&& gemini --version > /dev/null \
|
2025-04-20 08:22:17 -07:00
|
|
|
&& npm cache clean --force \
|
2025-09-25 11:26:07 -07:00
|
|
|
&& rm -f /tmp/gemini-{cli,core}.tgz
|
2025-05-29 21:01:44 +00:00
|
|
|
|
2025-05-29 22:16:39 +00:00
|
|
|
# default entrypoint when none specified
|
2026-05-05 01:21:06 +05:30
|
|
|
ENTRYPOINT ["/usr/local/share/npm-global/bin/gemini"]
|