mirror of
https://github.com/NVIDIA/OpenShell.git
synced 2026-10-26 06:52:57 +08:00
## Summary - Track last deployed local changes and only redeploy new deltas in auto mode. - Add per-component fingerprints (server/sandbox/helm) persisted to .cache/cluster-deploy-fast.state. - Update docs for the new incremental deploy behavior. ``` mise run cluster .... ________________________________________________________ Executed in 75.21 secs fish external usr time 578.03 millis 0.25 millis 577.78 millis sys time 364.45 millis 1.22 millis 363.22 millis ``` with a change to `navigator-sandbox` (triggers rust recompile) ``` ⟩ time mise run cluster:deploy [cluster:deploy] $ build/scripts/cluster-deploy-fast.sh Change detection took 0s Fast deploy plan: build server: 0 build sandbox: 1 helm upgrade: 1 ... ________________________________________________________ Executed in 25.88 secs fish external usr time 618.91 millis 0.24 millis 618.67 millis sys time 557.71 millis 1.54 millis 556.18 millis ``` (most time is spent in docker build) ## Test Plan - mise run pre-commit
91 lines
3.2 KiB
Bash
Executable File
91 lines
3.2 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Generic Docker image builder for Navigator components.
|
|
# Usage: docker-build-component.sh <component> [variant] [extra docker build args...]
|
|
#
|
|
# Components with a subdirectory layout (e.g. deploy/docker/sandbox/) support
|
|
# an optional variant argument:
|
|
# docker-build-component.sh sandbox -> Dockerfile.base -> navigator/sandbox:dev
|
|
# docker-build-component.sh sandbox nvidia -> Dockerfile.nvidia -> navigator/sandbox-nvidia:dev
|
|
#
|
|
# Components without a subdirectory use the flat layout:
|
|
# docker-build-component.sh server -> Dockerfile.server -> navigator/server:dev
|
|
#
|
|
# Environment:
|
|
# IMAGE_TAG - Image tag (default: dev)
|
|
# DOCKER_PLATFORM - Target platform (optional, e.g. linux/amd64)
|
|
# DOCKER_BUILDER - Buildx builder name (default: auto-select)
|
|
set -euo pipefail
|
|
|
|
COMPONENT=${1:?"Usage: docker-build-component.sh <component> [variant] [extra-args...]"}
|
|
shift
|
|
|
|
# Resolve Dockerfile path and image name.
|
|
# If the component has a subdirectory layout, consume the next positional arg
|
|
# as a variant name (default: base).
|
|
VARIANT=""
|
|
COMPONENT_DIR="deploy/docker/${COMPONENT}"
|
|
if [[ -d "${COMPONENT_DIR}" ]]; then
|
|
# Subdirectory layout — check for a variant argument.
|
|
if [[ $# -gt 0 && ! "$1" == --* ]]; then
|
|
VARIANT="$1"
|
|
shift
|
|
fi
|
|
VARIANT=${VARIANT:-base}
|
|
DOCKERFILE="${COMPONENT_DIR}/Dockerfile.${VARIANT}"
|
|
if [[ "${VARIANT}" == "base" ]]; then
|
|
IMAGE_NAME="navigator/${COMPONENT}"
|
|
else
|
|
IMAGE_NAME="navigator/${COMPONENT}-${VARIANT}"
|
|
fi
|
|
else
|
|
# Flat layout: deploy/docker/Dockerfile.<component>
|
|
DOCKERFILE="deploy/docker/Dockerfile.${COMPONENT}"
|
|
IMAGE_NAME="navigator/${COMPONENT}"
|
|
fi
|
|
|
|
if [[ ! -f "${DOCKERFILE}" ]]; then
|
|
echo "Error: Dockerfile not found: ${DOCKERFILE}" >&2
|
|
exit 1
|
|
fi
|
|
|
|
IMAGE_TAG=${IMAGE_TAG:-dev}
|
|
DOCKER_BUILD_CACHE_DIR=${DOCKER_BUILD_CACHE_DIR:-.cache/buildkit}
|
|
CACHE_PATH="${DOCKER_BUILD_CACHE_DIR}/${COMPONENT}${VARIANT:+-${VARIANT}}"
|
|
|
|
mkdir -p "${CACHE_PATH}"
|
|
|
|
# Select the builder. For local (single-arch) builds use a builder with the
|
|
# native "docker" driver so images land directly in the Docker image store —
|
|
# no slow tarball export via the docker-container driver.
|
|
# Multi-platform builds (DOCKER_PLATFORM set) keep the current builder which
|
|
# is typically docker-container.
|
|
BUILDER_ARGS=()
|
|
if [[ -n "${DOCKER_BUILDER:-}" ]]; then
|
|
BUILDER_ARGS=(--builder "${DOCKER_BUILDER}")
|
|
elif [[ -z "${DOCKER_PLATFORM:-}" && -z "${CI:-}" ]]; then
|
|
# Pick the builder matching the active docker context (uses docker driver).
|
|
_ctx=$(docker context inspect --format '{{.Name}}' 2>/dev/null || echo default)
|
|
BUILDER_ARGS=(--builder "${_ctx}")
|
|
fi
|
|
|
|
CACHE_ARGS=()
|
|
if [[ -n "${CI:-}" ]]; then
|
|
echo "CI environment detected; skipping local build cache export options."
|
|
elif docker buildx inspect ${BUILDER_ARGS[@]+"${BUILDER_ARGS[@]}"} 2>/dev/null | grep -q "Driver: docker-container"; then
|
|
CACHE_ARGS=(
|
|
--cache-from "type=local,src=${CACHE_PATH}"
|
|
--cache-to "type=local,dest=${CACHE_PATH},mode=max"
|
|
)
|
|
fi
|
|
|
|
docker buildx build \
|
|
${BUILDER_ARGS[@]+"${BUILDER_ARGS[@]}"} \
|
|
${DOCKER_PLATFORM:+--platform ${DOCKER_PLATFORM}} \
|
|
${CACHE_ARGS[@]+"${CACHE_ARGS[@]}"} \
|
|
-f "${DOCKERFILE}" \
|
|
-t "${IMAGE_NAME}:${IMAGE_TAG}" \
|
|
--provenance=false \
|
|
"$@" \
|
|
--load \
|
|
.
|