Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@
"features": {
"ghcr.io/devcontainers/features/sshd:1": {
"version": "latest"
},
"ghcr.io/devcontainers/features/github-cli:1": {
"version": "latest"
},
"ghcr.io/devcontainers/features/azure-cli:1": {
"version": "latest"
}
}
}
28 changes: 9 additions & 19 deletions .devcontainer/onCreate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,20 @@

set -e

echo "Installing the GitHub CLI"
(type -p wget >/dev/null || (sudo apt update && sudo apt-get install wget -y)) \
&& sudo mkdir -p -m 755 /etc/apt/keyrings \
&& out=$(mktemp) && wget -nv -O$out https://cli.github.com/packages/githubcli-archive-keyring.gpg \
&& cat $out | sudo tee /etc/apt/keyrings/githubcli-archive-keyring.gpg > /dev/null \
&& sudo chmod go+r /etc/apt/keyrings/githubcli-archive-keyring.gpg \
&& echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null \
&& sudo apt update \
&& sudo apt install gh inotify-tools -y
echo "Setting up node user home directory and permissions"
sudo mkdir -p /home/node/.config/vscode-dev-containers
sudo chown -R node:node /home/node
sudo chmod 755 /home/node
sudo chmod -R 755 /home/node/.config

echo "Installing azcopy"

sudo wget -O /usr/local/bin/azcopytar https://aka.ms/downloadazcopy-v10-linux
sudo tar -xvf /usr/local/bin/azcopytar -C /usr/local/bin/
sudo rm /usr/local/bin/azcopytar
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 inotify-tools"
sudo apt update && sudo apt install -y inotify-tools

SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
"$SCRIPT_DIR/refreshTools.sh"

echo "Pre-starting the server and generating the optimized assets"
npm run optimize --override
echo "Installing Node.js dependencies"
npm install

echo "Installing supervisor"
sudo apt-get update && sudo apt-get install -y supervisor
30 changes: 30 additions & 0 deletions .devcontainer/refreshTools.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ set -e

echo "Checking for updates to workbench-template from GitHub"

# Ensure jq is installed for JSON parsing
if ! command -v jq &> /dev/null; then
echo "Installing jq for JSON parsing..."
sudo apt-get update && sudo apt-get install -y jq
fi

WORKSPACE_DIR="/workspaces/spark-template"

MARKER_DIR="/var/lib/spark/.versions"
Expand All @@ -12,11 +18,28 @@ TOOLS_MARKER_FILE="$MARKER_DIR/tools"

sudo mkdir -p "$MARKER_DIR"

# Check if TEMPLATE_PAT is set
if [ -z "$TEMPLATE_PAT" ]; then
echo "TEMPLATE_PAT environment variable is not set. Skipping tools update."
exit 0
fi

# Fetch the latest release information
LATEST_RELEASE=$(curl -s -H "Authorization: token $TEMPLATE_PAT" https://api.github.com/repos/github/spark-template/releases/latest)

# Check if the API call succeeded
if [ $? -ne 0 ] || [ -z "$LATEST_RELEASE" ]; then
echo "Failed to fetch release information from GitHub. Skipping tools update."
exit 0
fi

# Check if marker file exists and has the same release ID
RELEASE_ID=$(echo "$LATEST_RELEASE" | jq -r '.id')
if [ "$RELEASE_ID" == "null" ] || [ -z "$RELEASE_ID" ]; then
echo "Invalid release data received from GitHub. Skipping tools update."
exit 0
fi

if [ -f "$RELEASE_MARKER_FILE" ] && [ "$(cat "$RELEASE_MARKER_FILE")" == "$RELEASE_ID" ]; then
echo "Already at the latest release. Skipping download."
exit 0
Expand All @@ -28,6 +51,13 @@ TEMP_DIR=$(mktemp -d)
cd $TEMP_DIR

DOWNLOAD_URL=$(echo "$LATEST_RELEASE" | jq -r '.assets[0].url')
if [ "$DOWNLOAD_URL" == "null" ] || [ -z "$DOWNLOAD_URL" ]; then
echo "No download URL found in release data. Skipping tools update."
cd - >/dev/null
rm -rf $TEMP_DIR
exit 0
fi

curl -L -o dist.zip -H "Authorization: token $TEMPLATE_PAT" -H "Accept: application/octet-stream" "$DOWNLOAD_URL"

unzip -o dist.zip
Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
"lint": "eslint .",
"test": "vitest",
"test:run": "vitest run",
"optimize": "vite optimize",
"preview": "vite preview",
"build:pages": "bash ./build-for-gh-pages.sh",
"predeploy": "npm run build:pages",
Expand Down
Loading