diff --git a/.dockerignore b/.dockerignore index ca3815b41..710f62536 100644 --- a/.dockerignore +++ b/.dockerignore @@ -5,6 +5,7 @@ !docker/ !docker/Dockerfile.run_with_importer !src/ +!.cargo/ !Cargo.toml !Cargo.lock !static/ diff --git a/chaos/install-dependencies.sh b/chaos/install-dependencies.sh index 34e8f111b..a8a574d20 100755 --- a/chaos/install-dependencies.sh +++ b/chaos/install-dependencies.sh @@ -1,27 +1,36 @@ -#!/bin/sh - -echo "Checking OS and installing dependencies..." - -if [ "$(uname)" = "Darwin" ]; then - echo "Installing dependencies for macOS..." - if ! [ -x "$(command -v kind)" ]; then - brew install kind - fi - if ! [ -x "$(command -v kubectl)" ]; then - brew install kubectl - fi +#!/bin/bash + +set -e + +echo "Checking if Kind cluster exists..." +if ! kind get clusters | grep -q local-testing; then + echo "Setting up Kind cluster..." + kind create cluster --name local-testing + kind get kubeconfig --name local-testing > kubeconfig.yaml else - echo "Installing dependencies for Linux..." - if ! [ -x "$(command -v kind)" ]; then - curl -Lo ./kind https://kind.sigs.k8s.io/dl/v0.11.1/kind-linux-amd64 - chmod +x ./kind - sudo mv ./kind /usr/local/bin/kind - fi - if ! [ -x "$(command -v kubectl)" ]; then - curl -LO "https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl" - chmod +x ./kubectl - sudo mv ./kubectl /usr/local/bin/kubectl - fi + echo "Kind cluster already exists." fi -echo "Dependencies installed" +echo "Configuring kubectl to use Kind cluster..." +export KUBECONFIG=$(pwd)/kubeconfig.yaml + +echo "Checking if Docker image is already built..." +if ! docker images | grep -q local/run_with_importer; then + echo "Building Docker image..." + docker build -t local/run_with_importer -f ./docker/Dockerfile.run_with_importer . +else + echo "Docker image already built." +fi + +echo "Loading Docker image into Kind..." +kind load docker-image local/run_with_importer --name local-testing + +echo "Deploying application..." +kubectl apply -f chaos/local-deployment.yaml +kubectl apply -f chaos/local-service.yaml + +echo "Waiting for pods to be ready..." +kubectl wait --for=condition=ready pod -l app=stratus-api --timeout=180s + +echo "Deployment complete. Checking pod status..." +kubectl get pods -o wide \ No newline at end of file diff --git a/docker/Dockerfile.run_with_importer b/docker/Dockerfile.run_with_importer index f1c5fe018..fd148e067 100644 --- a/docker/Dockerfile.run_with_importer +++ b/docker/Dockerfile.run_with_importer @@ -8,6 +8,7 @@ COPY .sqlx /app/.sqlx COPY build.rs /app/build.rs COPY Cargo.toml /app/Cargo.toml COPY Cargo.lock /app/Cargo.lock +COPY .cargo .cargo RUN apt update RUN apt-get install -y libclang-dev cmake diff --git a/justfile b/justfile index 9a98bd801..5cf881406 100644 --- a/justfile +++ b/justfile @@ -450,15 +450,23 @@ local-chaos-setup: @echo $(pwd) @echo "Installing dependencies..." ./chaos/install-dependencies.sh - @echo "Cleaning up any existing Kind cluster..." - kind delete cluster --name local-testing || true - @echo "Setting up Kind cluster..." - kind create cluster --name local-testing + @echo "Checking if Kind cluster exists..." + if ! kind get clusters | grep -q local-testing; then \ + echo "Setting up Kind cluster..."; \ + kind create cluster --name local-testing; \ + kind get kubeconfig --name local-testing > kubeconfig.yaml; \ + else \ + echo "Kind cluster already exists."; \ + fi @echo "Configuring kubectl to use Kind cluster..." - kind get kubeconfig --name local-testing > kubeconfig.yaml export KUBECONFIG=$(pwd)/kubeconfig.yaml - @echo "Building Docker image..." - docker build -t local/run_with_importer -f ./docker/Dockerfile.run_with_importer . + @echo "Checking if Docker image is already built..." + if ! docker images | grep -q local/run_with_importer; then \ + echo "Building Docker image..."; \ + docker build -t local/run_with_importer -f ./docker/Dockerfile.run_with_importer .; \ + else \ + echo "Docker image already built."; \ + fi @echo "Loading Docker image into Kind..." kind load docker-image local/run_with_importer --name local-testing @echo "Deploying application..." @@ -475,7 +483,6 @@ local-chaos-cleanup: kind delete cluster --name local-testing @echo "Cleanup complete." - # Chaos Testing: Run chaos test local-chaos-test: just local-chaos-setup