Unverified Commit 111e08c5 authored by Keiven C's avatar Keiven C Committed by GitHub
Browse files

refactor: simplify, remove --dev-image option from build.sh (#4867)


Signed-off-by: default avatarKeiven Chang <keivenchang@users.noreply.github.com>
Co-authored-by: default avatarKeiven Chang <keivenchang@users.noreply.github.com>
parent f8bb53c0
...@@ -161,23 +161,6 @@ The `build.sh` script is responsible for building Docker images for different AI ...@@ -161,23 +161,6 @@ The `build.sh` script is responsible for building Docker images for different AI
./build.sh --build-arg CUSTOM_ARG=value ./build.sh --build-arg CUSTOM_ARG=value
``` ```
### build.sh --dev-image - Local Development Image Builder
The `build.sh --dev-image` option takes a dev image and then builds a local-dev image, which contains proper local user permissions. It also includes extra developer utilities (debugging tools, text editors, system monitors, etc.).
**Common Usage Examples:**
```bash
# Build local-dev image from dev image dynamo:latest-vllm
./build.sh --dev-image dynamo:latest-vllm --framework vllm
# Build with custom tag from dev image dynamo:latest-vllm
./build.sh --dev-image dynamo:latest-vllm --framework vllm --tag my-local:dev
# Dry run to see what would be built
./build.sh --dev-image dynamo:latest-vllm --framework vllm --dry-run
```
### Building the Frontend Image ### Building the Frontend Image
The frontend image is a specialized container that includes the Dynamo components (NATS, etcd, dynamo, NIXL, etc) along with the Endpoint Picker (EPP) for Kubernetes Gateway API Inference Extension integration. This image is primarily used for inference gateway deployments. The frontend image is a specialized container that includes the Dynamo components (NATS, etcd, dynamo, NIXL, etc) along with the Endpoint Picker (EPP) for Kubernetes Gateway API Inference Extension integration. This image is primarily used for inference gateway deployments.
......
...@@ -199,7 +199,6 @@ get_options() { ...@@ -199,7 +199,6 @@ get_options() {
fi fi
;; ;;
--base-image) --base-image)
# Note: --base-image cannot be used with --dev-image
if [ "$2" ]; then if [ "$2" ]; then
BASE_IMAGE=$2 BASE_IMAGE=$2
shift shift
...@@ -223,14 +222,6 @@ get_options() { ...@@ -223,14 +222,6 @@ get_options() {
missing_requirement "$1" missing_requirement "$1"
fi fi
;; ;;
--dev-image)
if [ "$2" ]; then
DEV_IMAGE_INPUT=$2
shift
else
missing_requirement "$1"
fi
;;
--uid) --uid)
if [ "$2" ]; then if [ "$2" ]; then
CUSTOM_UID=$2 CUSTOM_UID=$2
...@@ -353,20 +344,10 @@ get_options() { ...@@ -353,20 +344,10 @@ get_options() {
shift shift
done done
# Validate argument combinations # Validate that --uid and --gid are only used with local-dev target
if [[ -n "${DEV_IMAGE_INPUT:-}" && -n "${BASE_IMAGE:-}" ]]; then
error "ERROR: --dev-image cannot be used with --base-image. Use --dev-image to build from existing images or --base-image to build new images."
fi
# Validate that --target and --dev-image cannot be used together
if [[ -n "${DEV_IMAGE_INPUT:-}" && -n "${TARGET:-}" ]]; then
error "ERROR: --target cannot be used with --dev-image. Use --target to build from scratch or --dev-image to build from existing images."
fi
# Validate that --uid and --gid are only used with local-dev related options
if [[ -n "${CUSTOM_UID:-}" || -n "${CUSTOM_GID:-}" ]]; then if [[ -n "${CUSTOM_UID:-}" || -n "${CUSTOM_GID:-}" ]]; then
if [[ -z "${DEV_IMAGE_INPUT:-}" && "${TARGET:-}" != "local-dev" ]]; then if [[ "${TARGET:-}" != "local-dev" ]]; then
error "ERROR: --uid and --gid can only be used with --dev-image or --target local-dev" error "ERROR: --uid and --gid can only be used with --target local-dev"
fi fi
fi fi
...@@ -468,9 +449,8 @@ show_help() { ...@@ -468,9 +449,8 @@ show_help() {
echo " [--cache-from cache location to start from]" echo " [--cache-from cache location to start from]"
echo " [--cache-to location where to cache the build output]" echo " [--cache-to location where to cache the build output]"
echo " [--tag tag for image]" echo " [--tag tag for image]"
echo " [--dev-image dev image to build local-dev from]" echo " [--uid user ID for local-dev images (only with --target local-dev)]"
echo " [--uid user ID for local-dev images (only with --dev-image or --target local-dev)]" echo " [--gid group ID for local-dev images (only with --target local-dev)]"
echo " [--gid group ID for local-dev images (only with --dev-image or --target local-dev)]"
echo " [--no-cache disable docker build cache]" echo " [--no-cache disable docker build cache]"
echo " [--dry-run print docker commands without running]" echo " [--dry-run print docker commands without running]"
echo " [--build-context name=path to add build context]" echo " [--build-context name=path to add build context]"
...@@ -876,54 +856,27 @@ fi ...@@ -876,54 +856,27 @@ fi
show_image_options show_image_options
if [ -z "$RUN_PREFIX" ]; then # Always build the main image first
set -x # Create build log directory for BuildKit reports
fi BUILD_LOG_DIR="${BUILD_CONTEXT}/build-logs"
mkdir -p "${BUILD_LOG_DIR}"
SINGLE_BUILD_LOG="${BUILD_LOG_DIR}/single-stage-build.log"
# Skip Build 1 and Build 2 if DEV_IMAGE_INPUT is set (we'll handle it at the bottom)
if [[ -z "${DEV_IMAGE_INPUT:-}" ]]; then
# Create build log directory for BuildKit reports
BUILD_LOG_DIR="${BUILD_CONTEXT}/build-logs"
mkdir -p "${BUILD_LOG_DIR}"
SINGLE_BUILD_LOG="${BUILD_LOG_DIR}/single-stage-build.log"
# Use BuildKit for enhanced metadata
if [ -z "$RUN_PREFIX" ]; then
if docker buildx version &>/dev/null; then
docker buildx build --progress=plain --load -f $DOCKERFILE $TARGET_STR $PLATFORM $BUILD_ARGS $CACHE_FROM $CACHE_TO $TAG $LATEST_TAG $BUILD_CONTEXT_ARG $BUILD_CONTEXT $NO_CACHE 2>&1 | tee "${SINGLE_BUILD_LOG}"
BUILD_EXIT_CODE=${PIPESTATUS[0]}
else
DOCKER_BUILDKIT=1 docker build --progress=plain -f $DOCKERFILE $TARGET_STR $PLATFORM $BUILD_ARGS $CACHE_FROM $CACHE_TO $TAG $LATEST_TAG $BUILD_CONTEXT_ARG $BUILD_CONTEXT $NO_CACHE 2>&1 | tee "${SINGLE_BUILD_LOG}"
BUILD_EXIT_CODE=${PIPESTATUS[0]}
fi
if [ ${BUILD_EXIT_CODE} -ne 0 ]; then # Use BuildKit for enhanced metadata
exit ${BUILD_EXIT_CODE} if docker buildx version &>/dev/null; then
fi $RUN_PREFIX docker buildx build --progress=plain --load -f $DOCKERFILE $TARGET_STR $PLATFORM $BUILD_ARGS $CACHE_FROM $CACHE_TO $TAG $LATEST_TAG $BUILD_CONTEXT_ARG $BUILD_CONTEXT $NO_CACHE 2>&1 | tee "${SINGLE_BUILD_LOG}"
else BUILD_EXIT_CODE=${PIPESTATUS[0]}
$RUN_PREFIX docker build -f $DOCKERFILE $TARGET_STR $PLATFORM $BUILD_ARGS $CACHE_FROM $CACHE_TO $TAG $LATEST_TAG $BUILD_CONTEXT_ARG $BUILD_CONTEXT $NO_CACHE else
fi $RUN_PREFIX DOCKER_BUILDKIT=1 docker build --progress=plain -f $DOCKERFILE $TARGET_STR $PLATFORM $BUILD_ARGS $CACHE_FROM $CACHE_TO $TAG $LATEST_TAG $BUILD_CONTEXT_ARG $BUILD_CONTEXT $NO_CACHE 2>&1 | tee "${SINGLE_BUILD_LOG}"
BUILD_EXIT_CODE=${PIPESTATUS[0]}
fi fi
# Handle --dev-image option (build local-dev from existing dev image) if [ ${BUILD_EXIT_CODE} -ne 0 ]; then
if [[ -n "${DEV_IMAGE_INPUT:-}" ]]; then exit ${BUILD_EXIT_CODE}
# Validate that the dev image is not already a local-dev image fi
if [[ "$DEV_IMAGE_INPUT" == *"-local-dev" ]]; then
echo "ERROR: Cannot use local-dev image as dev image input: '$DEV_IMAGE_INPUT'"
exit 1
fi
# Build tag arguments - always add -local-dev suffix for --dev-image
# Generate local-dev tag from input image
if [[ "$DEV_IMAGE_INPUT" == *:* ]]; then
LOCAL_DEV_TAG="--tag ${DEV_IMAGE_INPUT}-local-dev"
else
LOCAL_DEV_TAG="--tag ${DEV_IMAGE_INPUT}:latest-local-dev"
fi
build_local_dev_with_header "$DEV_IMAGE_INPUT" "$LOCAL_DEV_TAG" "Successfully built local-dev image: ${LOCAL_DEV_TAG#--tag }" "Building Local-Dev Image" # Handle local-dev target
elif [[ "${LOCAL_DEV_BUILD:-}" == "true" ]]; then if [[ "${LOCAL_DEV_BUILD:-}" == "true" ]]; then
# Use the first tag name (TAG) if available, otherwise use latest # Use the first tag name (TAG) if available, otherwise use latest
if [[ -n "$TAG" ]]; then if [[ -n "$TAG" ]]; then
DEV_IMAGE=$(echo "$TAG" | sed 's/--tag //' | sed 's/-local-dev$//') DEV_IMAGE=$(echo "$TAG" | sed 's/--tag //' | sed 's/-local-dev$//')
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment