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
44 changes: 44 additions & 0 deletions .devcontainer/dapr/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{
"name": "Drasi For Dapr",
"image": "mcr.microsoft.com/devcontainers/base:ubuntu",
"workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}/tutorial/dapr",
"onCreateCommand": "bash ../../.devcontainer/dapr/on-create.sh",
"postCreateCommand": "bash ../../.devcontainer/dapr/post-create.sh",
"runArgs": [
"--privileged",
"--init"
],
"customizations": {
"vscode": {
"extensions": [
"DrasiProject.drasi",
"cweijan.vscode-database-client2"
]
}
},
"features": {
"ghcr.io/devcontainers/features/docker-in-docker:2": {}
},
"containerEnv": {
"LANG": "en_US.UTF-8",
"LANGUAGE": "en_US:en",
"LC_ALL": "en_US.UTF-8"
},
"remoteEnv": {
"LOCAL_WORKSPACE_FOLDER": "${localWorkspaceFolder}"
},
"forwardPorts": [8123],
"portsAttributes": {
"8123": {
"label": "Dapr + Drasi Apps",
"onAutoForward": "notify",
"protocol": "http"
}
},

"hostRequirements": {
"cpus": 4,
"memory": "8gb",
"storage": "32gb"
}
}
27 changes: 27 additions & 0 deletions .devcontainer/dapr/on-create.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/bin/sh
# Copyright 2025 The Drasi Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# Install kubectl
sudo apt-get update
sudo apt-get install -y ca-certificates curl gnupg
curl -fsSL https://pkgs.k8s.io/core:/stable:/v1.31/deb/Release.key | sudo gpg --dearmor -o /etc/apt/keyrings/kubernetes-apt-keyring.gpg
sudo chmod 644 /etc/apt/keyrings/kubernetes-apt-keyring.gpg
echo 'deb [signed-by=/etc/apt/keyrings/kubernetes-apt-keyring.gpg] https://pkgs.k8s.io/core:/stable:/v1.31/deb/ /' | sudo tee /etc/apt/sources.list.d/kubernetes.list
sudo chmod 644 /etc/apt/sources.list.d/kubernetes.list
sudo apt-get update
sudo apt-get install -y kubectl

## Install Drasi CLI
curl -fsSL https://raw.githubusercontent.com/drasi-project/drasi-platform/main/cli/installers/install-drasi-cli.sh | /bin/bash
68 changes: 68 additions & 0 deletions .devcontainer/dapr/post-create.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
#!/bin/bash
# Copyright 2025 The Drasi Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

set -e

# Define k3d version to use across all environments
K3D_VERSION="v5.6.0"

# Ensure kubectl is available
if ! command -v kubectl &> /dev/null; then
echo "kubectl not found in PATH. Attempting to install..."
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
chmod +x kubectl
sudo mv kubectl /usr/local/bin/
fi

# Verify kubectl is available
if ! command -v kubectl &> /dev/null; then
echo "ERROR: kubectl is still not available. Please check the installation."
exit 1
fi

# Install k3d if not present
if ! command -v k3d &> /dev/null; then
echo "k3d not found. Installing k3d ${K3D_VERSION}..."
curl -s https://raw.githubusercontent.com/k3d-io/k3d/main/install.sh | TAG=${K3D_VERSION} bash
else
echo "k3d is already installed: $(k3d version | grep 'k3d version' || echo 'version unknown')"
fi

# Verify k3d is available
if ! command -v k3d &> /dev/null; then
echo "ERROR: k3d installation failed."
exit 1
fi

echo "Running setup script..."
# The working directory is already set by workspaceFolder in devcontainer.json
bash scripts/setup-tutorial.sh

echo ""
echo "Setup complete! Applications are available at:"
echo " Catalog UI: http://localhost:8123/catalogue-service"
echo " Dashboard UI: http://localhost:8123/dashboard"
echo " Notifications UI: http://localhost:8123/notifications-service"
echo ""
echo "To deploy Drasi components:"
echo " kubectl apply -f drasi/sources/"
echo " kubectl apply -f drasi/queries/"
echo " kubectl apply -f drasi/reactions/"
echo ""
echo "Then run the demo scripts:"
echo " cd demo"
echo " ./demo-catalogue-service.sh"
echo " ./demo-dashboard-service.sh"
echo " ./demo-notifications-service.sh"
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ Following sample applications demonstrate usage of Drasi in different scenarios:
3. [Fleet POC](https://github.com/drasi-project/learning/tree/main/apps/fleet-poc)- Drasi for an efficient solution to translate vehicle telemetery into actionable insights for Connected Fleet scenarios
5. [Non-events](https://github.com/drasi-project/learning/tree/main/apps/non-events) - An app to demonstrate Drasi's abilities to trigger alerts when events do not occur within a stipulated time window.
6. [Trivia](https://github.com/drasi-project/learning/tree/main/apps/trivia)- A trivia game app with dashboards that are updated directly by Drasi when team and player scores change or when players are inactive for a period of time.
7. [Dapr](https://github.com/drasi-project/learning/tree/main/apps/dapr) - A set of dapr applications that demonstrate Drasi's abilities within a dapr microservice ecosystem.
36 changes: 32 additions & 4 deletions scripts/build-and-push-tutorial.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ set -e
# Validate arguments
if [ $# -lt 1 ]; then
echo "Usage: $0 <tutorial-name> [tag]"
echo "Available tutorials: curbside-pickup, building-comfort"
echo "Available tutorials: curbside-pickup, building-comfort, dapr"
echo "Default tag: latest"
exit 1
fi
Expand All @@ -39,7 +39,7 @@ PROJECT_ROOT="$( cd "$SCRIPT_DIR/.." && pwd )"

# Validate tutorial name
case $TUTORIAL in
"curbside-pickup"|"building-comfort")
"curbside-pickup"|"building-comfort"|"dapr")
TUTORIAL_DIR="$PROJECT_ROOT/tutorial/$TUTORIAL"
if [ ! -d "$TUTORIAL_DIR" ]; then
echo "Error: Tutorial directory not found: $TUTORIAL_DIR"
Expand All @@ -48,7 +48,7 @@ case $TUTORIAL in
;;
*)
echo "Error: Invalid tutorial name '$TUTORIAL'"
echo "Available tutorials: curbside-pickup, building-comfort"
echo "Available tutorials: curbside-pickup, building-comfort, dapr"
exit 1
;;
esac
Expand Down Expand Up @@ -123,8 +123,36 @@ case $TUTORIAL in
build_and_push "dashboard" "./dashboard"
build_and_push "demo" "./demo"
;;

"dapr")
# Check for missing package-lock.json files for frontend services
check_npm_lock "./services/catalogue"
check_npm_lock "./services/dashboard"
check_npm_lock "./services/notifications/ui"

# Build all dapr tutorial images
build_and_push "products-service" "./services/products"
build_and_push "customers-service" "./services/customers"
build_and_push "orders-service" "./services/orders"
build_and_push "reviews-service" "./services/reviews"
build_and_push "catalogue-service" "./services/catalogue"
build_and_push "dashboard-service" "./services/dashboard"
build_and_push "notifications-service" "./services/notifications"
;;
esac

echo ""
echo "All images for $TUTORIAL tutorial have been built and pushed with tag: $TAG"
echo "Total images built: $([ "$TUTORIAL" = "curbside-pickup" ] && echo "5" || echo "3")"

# Count images based on tutorial
case $TUTORIAL in
"curbside-pickup")
echo "Total images built: 5"
;;
"building-comfort")
echo "Total images built: 3"
;;
"dapr")
echo "Total images built: 7"
;;
esac
Loading