diff --git a/.gitignore b/.gitignore index 63dfa5623b..7ae36c470e 100644 --- a/.gitignore +++ b/.gitignore @@ -165,6 +165,5 @@ CLAUDE.local.md # ignore merged schema data/merged_schema.graphql -# webui release download temp directories -temp-webui-* -backend.ai-webui-bundle-*.zip \ No newline at end of file +# webui release download temp directories (safe to delete) +scripts/temp-releases/ \ No newline at end of file diff --git a/scripts/serve-release.sh b/scripts/serve-release.sh index 0c40067ab7..c102887f66 100755 --- a/scripts/serve-release.sh +++ b/scripts/serve-release.sh @@ -15,12 +15,21 @@ VERSION="$1" # Remove 'v' prefix if present VERSION="${VERSION#v}" +# Get script directory and project root +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +PROJECT_ROOT="$(dirname "${SCRIPT_DIR}")" + +# Create temp directory structure +TEMP_BASE="${SCRIPT_DIR}/temp-releases" +mkdir -p "${TEMP_BASE}" + # Construct the download URL and filename FILENAME="backend.ai-webui-bundle-${VERSION}.zip" URL="https://github.com/lablup/backend.ai-webui/releases/download/v${VERSION}/${FILENAME}" -# Create a temporary directory for extraction -TEMP_DIR="temp-webui-${VERSION}" +# Set paths in temp directory +DOWNLOAD_PATH="${TEMP_BASE}/${FILENAME}" +TEMP_DIR="${TEMP_BASE}/webui-${VERSION}" # Check if the version folder already exists if [ -d "${TEMP_DIR}" ]; then @@ -32,17 +41,17 @@ if [ -d "${TEMP_DIR}" ]; then EXTRACTED_FOLDER="${TEMP_DIR}" fi else - echo "Downloading ${FILENAME}..." - curl -L -o "${FILENAME}" "${URL}" + echo "Downloading ${FILENAME} to ${TEMP_BASE}..." + curl -L -o "${DOWNLOAD_PATH}" "${URL}" - if [ ! -f "${FILENAME}" ]; then + if [ ! -f "${DOWNLOAD_PATH}" ]; then echo "Error: Failed to download ${FILENAME}" exit 1 fi echo "Extracting ${FILENAME}..." rm -rf "${TEMP_DIR}" - unzip -q "${FILENAME}" -d "${TEMP_DIR}" + unzip -q "${DOWNLOAD_PATH}" -d "${TEMP_DIR}" # Find the extracted folder (it might be nested) EXTRACTED_FOLDER=$(find "${TEMP_DIR}" -type d -name "*webui*" | head -1) @@ -50,10 +59,15 @@ else # If no webui folder found, use the temp directory itself EXTRACTED_FOLDER="${TEMP_DIR}" fi + + # Optionally remove the zip file after extraction to save space + echo "Removing downloaded zip file..." + rm "${DOWNLOAD_PATH}" fi -echo "Copying config.toml to extracted folder..." -cp config.toml "${EXTRACTED_FOLDER}/" +echo "Overwriting config.toml and plugins to extracted folder..." +cp "${PROJECT_ROOT}/config.toml" "${EXTRACTED_FOLDER}/" +cp -r "${PROJECT_ROOT}/dist/plugins" "${EXTRACTED_FOLDER}/dist/" echo "Starting server in ${EXTRACTED_FOLDER}..." cd "${EXTRACTED_FOLDER}"