diff --git a/.devcontainer/onCreate.sh b/.devcontainer/onCreate.sh index 1cb26c6..34bb94e 100755 --- a/.devcontainer/onCreate.sh +++ b/.devcontainer/onCreate.sh @@ -21,9 +21,14 @@ azcopy_dir=$(find /usr/local/bin/ -type d -name "azcopy*" | head -n 1) sudo mv "$azcopy_dir/azcopy" /usr/local/bin/azcopy sudo rm -rf "$azcopy_dir" +echo "Installing sdk" + SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" -"$SCRIPT_DIR/refreshTools.sh" +LATEST_RELEASE=$(bash "$SCRIPT_DIR/refreshTools.sh") +cd /tmp/spark +LATEST_RELEASE="$LATEST_RELEASE" WORKSPACE_DIR="$WORKSPACE_DIR" bash spark-sdk-dist/install-tools.sh +cd /workspaces/spark-template echo "Pre-starting the server and generating the optimized assets" npm run optimize --override diff --git a/.devcontainer/postStartCommand.sh b/.devcontainer/postStartCommand.sh index be5d3b1..03a4e92 100755 --- a/.devcontainer/postStartCommand.sh +++ b/.devcontainer/postStartCommand.sh @@ -1,7 +1,21 @@ #!/bin/bash SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" -bash "$SCRIPT_DIR/refreshTools.sh" +LATEST_RELEASE=$(bash "$SCRIPT_DIR/refreshTools.sh") + +sudo cp .devcontainer/spark.conf /etc/supervisor/conf.d/ + +cd /tmp/spark +bash spark-sdk-dist/repair.sh +LATEST_RELEASE="$LATEST_RELEASE" WORKSPACE_DIR="$WORKSPACE_DIR" bash /tmp/spark/spark-sdk-dist/install-tools.sh services +cd /workspaces/spark-template + +sudo chown node /var/run/ +sudo chown -R node /var/log/ + +supervisord +supervisorctl reread +supervisorctl update # Check if SNAPSHOT_SAS_URL was passed, if so run hydrate.sh if [ -n "$SNAPSHOT_SAS_URL" ]; then @@ -9,19 +23,20 @@ if [ -n "$SNAPSHOT_SAS_URL" ]; then SAS_URI="$SNAPSHOT_SAS_URL" /usr/local/bin/hydrate.sh $WORKSPACE_DIR fi +cd /tmp/spark +LATEST_RELEASE="$LATEST_RELEASE" WORKSPACE_DIR="$WORKSPACE_DIR" bash /tmp/spark/spark-sdk-dist/install-tools.sh sdk +cd /workspaces/spark-template + # Keep reflog commits "forever" git config gc.reflogExpire 500.years.ago git config gc.reflogExpireUnreachable 500.years.ago -sudo cp .devcontainer/spark.conf /etc/supervisor/conf.d/ -sudo chown node /var/run/ -sudo chown -R node /var/log/ - -supervisord -supervisorctl reread -supervisorctl update # Set up post-commit hook and also run the build script to perform a one-time build for static preview ln -fs /usr/local/bin/post-commit .git/hooks/post-commit /usr/local/bin/static-preview-build.sh + +cd /tmp/spark +LATEST_RELEASE="$LATEST_RELEASE" WORKSPACE_DIR="$WORKSPACE_DIR" bash /tmp/spark/spark-sdk-dist/install-tools.sh cli +cd /workspaces/spark-template diff --git a/.devcontainer/refreshTools.sh b/.devcontainer/refreshTools.sh index f960469..ce2aea6 100755 --- a/.devcontainer/refreshTools.sh +++ b/.devcontainer/refreshTools.sh @@ -2,22 +2,19 @@ set -e -echo "Checking for updates..." - WORKSPACE_DIR="/workspaces/spark-template" LATEST_RELEASE=$(curl -s https://api.github.com/repos/github/spark-template/releases/latest) -echo "New version found. Downloading latest release." +RELEASE_ID=$(echo "$LATEST_RELEASE" | jq -r '.id') + -TEMP_DIR=$(mktemp -d) -cd $TEMP_DIR +TEMP_DIR=/tmp/spark +rm -rf $TEMP_DIR +mkdir -p $TEMP_DIR DOWNLOAD_URL=$(echo "$LATEST_RELEASE" | jq -r '.assets[0].url') -curl -L -o dist.zip -H "Accept: application/octet-stream" "$DOWNLOAD_URL" +curl -L -o "$TEMP_DIR/dist.zip" -H "Accept: application/octet-stream" "$DOWNLOAD_URL" -unzip -o dist.zip -rm dist.zip -DIST_DIR="spark-sdk-dist" +unzip -o "$TEMP_DIR/dist.zip" -d "$TEMP_DIR" +rm "$TEMP_DIR/dist.zip" -bash spark-sdk-dist/repair.sh -LATEST_RELEASE="$LATEST_RELEASE" DIST_DIR="$DIST_DIR" WORKSPACE_DIR="$WORKSPACE_DIR" bash spark-sdk-dist/install-tools.sh -rm -rf $TEMP_DIR \ No newline at end of file +echo "$RELEASE_ID" \ No newline at end of file