feat(build): decouple maintainer image into dedicated Dockerfile

This commit is contained in:
mkorwel
2026-03-15 09:17:54 -07:00
parent f7d5510b8b
commit f7837d4d42
3 changed files with 68 additions and 31 deletions

View File

@@ -0,0 +1,52 @@
# --- STAGE 1: Base Runtime ---
FROM docker.io/library/node:20-slim AS base
ARG CLI_VERSION_ARG
ENV CLI_VERSION=$CLI_VERSION_ARG
RUN apt-get update && apt-get install -y --no-install-recommends \
python3 \
curl \
dnsutils \
less \
jq \
ca-certificates \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
# --- STAGE 2: Maintainer ---
FROM base AS maintainer
# Install "Maintainer Bloat" - tools needed for development and offloading
RUN apt-get update && apt-get install -y --no-install-recommends \
make \
g++ \
gh \
git \
unzip \
rsync \
ripgrep \
procps \
psmisc \
lsof \
socat \
build-essential \
libsecret-1-dev \
libkrb5-dev \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
# Install global dev tools
RUN npm install -g tsx vitest
# Set up npm global package folder
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
# Switch to non-root user node
USER node
# Default entrypoint
CMD ["/bin/bash"]

View File

@@ -47,7 +47,7 @@ steps:
env:
- 'GEMINI_SANDBOX=$_CONTAINER_TOOL'
# Step 6: Build maintainer container image (Maintainer stage)
# Step 6: Build maintainer container image (Dedicated Maintainer Dockerfile)
- name: 'us-west1-docker.pkg.dev/gemini-code-dev/gemini-code-containers/gemini-code-builder'
id: 'Build maintainer Docker image'
entrypoint: 'bash'
@@ -56,7 +56,7 @@ steps:
- |-
export TAG=$$(cat /workspace/image_tag.txt)
IMAGE_BASE="us-docker.pkg.dev/gemini-code-dev/gemini-cli/maintainer"
docker build --target maintainer -t "$${IMAGE_BASE}:$${TAG}" .
docker build -f .gcp/Dockerfile.maintainer -t "$${IMAGE_BASE}:$${TAG}" .
docker push "$${IMAGE_BASE}:$${TAG}"
env:
- 'GEMINI_SANDBOX=$_CONTAINER_TOOL'

View File

@@ -1,26 +1,21 @@
# --- STAGE 1: Base Runtime ---
FROM docker.io/library/node:20-slim AS base
FROM docker.io/library/node:20-slim
ARG SANDBOX_NAME="gemini-cli-sandbox"
ARG CLI_VERSION_ARG
ENV SANDBOX="$SANDBOX_NAME"
ENV CLI_VERSION=$CLI_VERSION_ARG
# install minimal set of packages, then clean up
RUN apt-get update && apt-get install -y --no-install-recommends \
python3 \
make \
g++ \
man-db \
curl \
dnsutils \
less \
jq \
ca-certificates \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
# --- STAGE 2: Maintainer (Parent of Sandbox) ---
FROM base AS maintainer
# Install "Maintainer Bloat" - tools needed for development and offloading
RUN apt-get update && apt-get install -y --no-install-recommends \
make \
g++ \
bc \
gh \
git \
unzip \
@@ -30,31 +25,21 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
psmisc \
lsof \
socat \
build-essential \
libsecret-1-dev \
libkrb5-dev \
ca-certificates \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
# Install global dev tools
RUN npm install -g tsx vitest
# Set up npm global package folder
# 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
# --- STAGE 3: Sandbox (Final CLI Image) ---
FROM maintainer AS sandbox
ARG SANDBOX_NAME="gemini-cli-sandbox"
ENV SANDBOX="$SANDBOX_NAME"
# Switch to non-root user node
# switch to non-root user node
USER node
# Install gemini-cli and clean up
# install gemini-cli and clean up
COPY packages/cli/dist/google-gemini-cli-*.tgz /tmp/gemini-cli.tgz
COPY packages/core/dist/google-gemini-cli-core-*.tgz /tmp/gemini-core.tgz
RUN npm install -g /tmp/gemini-core.tgz \
@@ -64,5 +49,5 @@ RUN npm install -g /tmp/gemini-core.tgz \
&& npm cache clean --force \
&& rm -f /tmp/gemini-{cli,core}.tgz
# Default entrypoint
# default entrypoint when none specified
CMD ["gemini"]