#!/usr/bin/env bash # ------------------------------------------------------------------ # 01_build_container.sh # Builds the Apptainer SIF image for vLLM inference. # This must be run FIRST — everything else runs inside the container. # # Usage: # bash 01_build_container.sh # ------------------------------------------------------------------ set -euo pipefail SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" DEF_FILE="${SCRIPT_DIR}/vllm_qwen.def" SIF_FILE="${SCRIPT_DIR}/vllm_qwen.sif" if [ -f "$SIF_FILE" ]; then echo "WARNING: ${SIF_FILE} already exists." read -p "Rebuild? [y/N] " confirm [[ "$confirm" =~ ^[Yy]$ ]] || exit 0 fi echo "=== Building Apptainer image from ${DEF_FILE} ===" echo " This will pull the vLLM Docker image and convert it." echo " Estimated time: 10-20 minutes depending on network speed." echo "" apptainer build --nv "$SIF_FILE" "$DEF_FILE" echo "" echo "=== Build complete ===" echo "Image: ${SIF_FILE}" ls -lh "$SIF_FILE"