diff --git a/examples/command/portals/ai/amazon_bedrock/ai_corp/run.sh b/examples/command/portals/ai/amazon_bedrock/ai_corp/run.sh index bfbdb901d48..ac83a490712 100755 --- a/examples/command/portals/ai/amazon_bedrock/ai_corp/run.sh +++ b/examples/command/portals/ai/amazon_bedrock/ai_corp/run.sh @@ -52,7 +52,8 @@ run() { aws ec2 create-key-pair --key-name "$key_name" --query 'KeyMaterial' > key.pem chmod 400 key.pem - sed "s/\$ENROLLMENT_TICKET/${enrollment_ticket}/g" run_ockam.sh > user_data.sh + sed "s/\$ENROLLMENT_TICKET/${enrollment_ticket}/g" run_ockam.sh > user_data1.sh + sed "s/\$OCKAM_VERSION/${OCKAM_VERSION}/g" user_data1.sh > user_data.sh instance_id=$(aws ec2 run-instances --image-id "$ami_id" --instance-type c5n.large \ --subnet-id "$subnet_id" --security-group-ids "$sg_id" \ --key-name "$key_name" --user-data file://user_data.sh --query 'Instances[0].InstanceId') @@ -128,7 +129,7 @@ get_configured_region() { cleanup() { # ---------------------------------------------------------------------------------------------------------------- # DELETE INSTANCE - rm -f user_data.sh + rm -f user_data*.sh instance_ids=$(aws ec2 describe-instances --filters "Name=tag:Name,Values=${name}-ec2-instance" \ --query "Reservations[].Instances[?State.Name!='terminated'].InstanceId[]") diff --git a/examples/command/portals/ai/amazon_bedrock/ai_corp/run_ockam.sh b/examples/command/portals/ai/amazon_bedrock/ai_corp/run_ockam.sh index 26df3439fdb..a931e57eaa9 100644 --- a/examples/command/portals/ai/amazon_bedrock/ai_corp/run_ockam.sh +++ b/examples/command/portals/ai/amazon_bedrock/ai_corp/run_ockam.sh @@ -7,6 +7,7 @@ sudo -u ec2-user bash << 'EOS' set -ex # Install Ockam Command +export OCKAM_VERSION="$OCKAM_VERSION" curl --proto '=https' --tlsv1.2 -sSfL https://install.command.ockam.io | bash source "$HOME/.ockam/env" diff --git a/examples/command/portals/ai/amazon_bedrock/health_corp/client.js b/examples/command/portals/ai/amazon_bedrock/health_corp/client.js index c78d3c7fc9f..981f02af256 100644 --- a/examples/command/portals/ai/amazon_bedrock/health_corp/client.js +++ b/examples/command/portals/ai/amazon_bedrock/health_corp/client.js @@ -10,8 +10,8 @@ async function run() { console.log("Connected to the model.\n\nApp: ", query); const queryResponse = await fetch("http://127.0.0.1:3000/query", { method: "POST", - headers: {"Content-Type": "application/json"}, - body: JSON.stringify({query}), + headers: { "Content-Type": "application/json" }, + body: JSON.stringify({ query }), keepalive: true, }); @@ -23,6 +23,7 @@ async function run() { const answer = await queryResponse.json(); console.log(answer['answer']); + console.log("\nThe example run was successful 🥳."); } catch (error) { console.log("Error:", error); } diff --git a/examples/command/portals/ai/amazon_bedrock/health_corp/run.sh b/examples/command/portals/ai/amazon_bedrock/health_corp/run.sh index f90acb0e1a6..9abaf3b7b00 100755 --- a/examples/command/portals/ai/amazon_bedrock/health_corp/run.sh +++ b/examples/command/portals/ai/amazon_bedrock/health_corp/run.sh @@ -44,14 +44,14 @@ run() { aws ec2 create-key-pair --key-name "${name}-key" --query 'KeyMaterial' > key.pem chmod 400 key.pem - sed "s/\$ENROLLMENT_TICKET/${enrollment_ticket}/g" run_ockam.sh > user_data.sh + sed "s/\$ENROLLMENT_TICKET/${enrollment_ticket}/g" run_ockam.sh > user_data1.sh + sed "s/\$OCKAM_VERSION/${OCKAM_VERSION}/g" user_data1.sh > user_data.sh instance_id=$(aws ec2 run-instances --image-id "$ami_id" --instance-type c5n.large \ --subnet-id "$subnet_id" --security-group-ids "$sg_id" \ --key-name "${name}-key" --user-data file://user_data.sh --query 'Instances[0].InstanceId') aws ec2 create-tags --resources "$instance_id" --tags "Key=Name,Value=${name}-ec2-instance" aws ec2 wait instance-running --instance-ids "$instance_id" ip=$(aws ec2 describe-instances --instance-ids "$instance_id" --query 'Reservations[0].Instances[0].PublicIpAddress') - rm -f user_data.sh until scp -o StrictHostKeyChecking=no -i ./key.pem ./client.js "ec2-user@$ip:client.js"; do sleep 10; done ssh -o StrictHostKeyChecking=no -i ./key.pem "ec2-user@$ip" \ @@ -65,7 +65,7 @@ cleanup() { # ---------------------------------------------------------------------------------------------------------------- # DELETE INSTANCE - rm -f user_data.sh + rm -rf user_data*.sh instance_ids=$(aws ec2 describe-instances --filters "Name=tag:Name,Values=${name}-ec2-instance" \ --query "Reservations[].Instances[?State.Name!='terminated'].InstanceId[]") for i in $instance_ids; do diff --git a/examples/command/portals/ai/amazon_bedrock/health_corp/run_ockam.sh b/examples/command/portals/ai/amazon_bedrock/health_corp/run_ockam.sh index fb689dfcd56..d69a79dd2cd 100755 --- a/examples/command/portals/ai/amazon_bedrock/health_corp/run_ockam.sh +++ b/examples/command/portals/ai/amazon_bedrock/health_corp/run_ockam.sh @@ -7,6 +7,7 @@ sudo -u ec2-user bash << 'EOS' set -ex # Install Ockam Command +export OCKAM_VERSION="$OCKAM_VERSION" curl --proto '=https' --tlsv1.2 -sSfL https://install.command.ockam.io | bash source "$HOME/.ockam/env" diff --git a/examples/command/portals/ai/amazon_bedrock/run.sh b/examples/command/portals/ai/amazon_bedrock/run.sh index a9cc0655dec..985e18e1981 100755 --- a/examples/command/portals/ai/amazon_bedrock/run.sh +++ b/examples/command/portals/ai/amazon_bedrock/run.sh @@ -44,6 +44,10 @@ run() { health_corp_ticket=$(ockam project ticket --usage-count 1 --expires-in 60m \ --attribute "ai-inlet=true") + if [[ -n "$OCKAM_VERSION" ]]; then + export OCKAM_VERSION="v${OCKAM_VERSION}"; + fi + # Invoke `ai_corp/run.sh` in the directory that has ai_corp's configuration. Pass the above # enrollment ticket as the first argument to run.sh script. Read ai_corp/run.sh to understand the parts # that are provisioned in ai_corp's virtual private cloud. diff --git a/examples/command/portals/ai/amazon_ec2/ai_corp/run.sh b/examples/command/portals/ai/amazon_ec2/ai_corp/run.sh index 831bad16233..6ba0fb24519 100755 --- a/examples/command/portals/ai/amazon_ec2/ai_corp/run.sh +++ b/examples/command/portals/ai/amazon_ec2/ai_corp/run.sh @@ -47,7 +47,8 @@ run() { # make sure that the current region supports the instance required to run the model check_if_instance_type_available g5g.2xlarge - sed "s/\$ENROLLMENT_TICKET/${enrollment_ticket}/g" run_ockam.sh > user_data.sh + sed "s/\$ENROLLMENT_TICKET/${enrollment_ticket}/g" run_ockam.sh > user_data1.sh + sed "s/\$OCKAM_VERSION/${OCKAM_VERSION}/g" user_data1.sh > user_data.sh instance_id=$(aws ec2 run-instances --image-id "$ami_id" --instance-type g5g.2xlarge \ --subnet-id "$subnet_id" --security-group-ids "$sg_id" \ --key-name "${name}-key" --user-data file://user_data.sh --query 'Instances[0].InstanceId') @@ -115,7 +116,7 @@ cleanup() { # ---------------------------------------------------------------------------------------------------------------- # DELETE INSTANCE - rm -f user_data.sh + rm -f user_data*.sh instance_ids=$(aws ec2 describe-instances --filters "Name=tag:Name,Values=${name}-ec2-instance" \ --query "Reservations[*].Instances[*].InstanceId") for i in $instance_ids; do @@ -132,8 +133,7 @@ cleanup() { # DELETE NETWORK vpc_ids=$(aws ec2 describe-vpcs \ - --filters "Name=tag:Name,Values=${name}-vpc") \ - --query 'Vpcs[*].VpcId' + --filters "Name=tag:Name,Values=${name}-vpc" --query 'Vpcs[*].VpcId') \ for vpc_id in $vpc_ids; do internet_gateways=$(aws ec2 describe-internet-gateways \ diff --git a/examples/command/portals/ai/amazon_ec2/ai_corp/run_ockam.sh b/examples/command/portals/ai/amazon_ec2/ai_corp/run_ockam.sh index f7e6d6290b1..69c91a754c0 100644 --- a/examples/command/portals/ai/amazon_ec2/ai_corp/run_ockam.sh +++ b/examples/command/portals/ai/amazon_ec2/ai_corp/run_ockam.sh @@ -7,6 +7,7 @@ sudo -u ec2-user bash << 'EOS' set -ex # Install Ockam Command +export OCKAM_VERSION="$OCKAM_VERSION" curl --proto '=https' --tlsv1.2 -sSfL https://install.command.ockam.io | bash source "$HOME/.ockam/env" diff --git a/examples/command/portals/ai/amazon_ec2/health_corp/client.js b/examples/command/portals/ai/amazon_ec2/health_corp/client.js index 66319c4b62d..c3e6501de12 100644 --- a/examples/command/portals/ai/amazon_ec2/health_corp/client.js +++ b/examples/command/portals/ai/amazon_ec2/health_corp/client.js @@ -21,6 +21,7 @@ async function run() { const answer = await queryResponse.json(); console.log(answer['answer']); + console.log("\nThe example run was successful 🥳."); } catch (error) { console.log("Error:", error.message); } diff --git a/examples/command/portals/ai/amazon_ec2/health_corp/run.sh b/examples/command/portals/ai/amazon_ec2/health_corp/run.sh index 6f62809ea5b..23b41cb6370 100755 --- a/examples/command/portals/ai/amazon_ec2/health_corp/run.sh +++ b/examples/command/portals/ai/amazon_ec2/health_corp/run.sh @@ -44,7 +44,8 @@ run() { aws ec2 create-key-pair --key-name "${name}-key" --query 'KeyMaterial' > key.pem chmod 400 key.pem - sed "s/\$ENROLLMENT_TICKET/${enrollment_ticket}/g" run_ockam.sh > user_data.sh + sed "s/\$ENROLLMENT_TICKET/${enrollment_ticket}/g" run_ockam.sh > user_data1.sh + sed "s/\$OCKAM_VERSION/${OCKAM_VERSION}/g" user_data1.sh > user_data.sh instance_id=$(aws ec2 run-instances --image-id "$ami_id" --instance-type c5n.large \ --subnet-id "$subnet_id" --security-group-ids "$sg_id" \ --key-name "${name}-key" --user-data file://user_data.sh --query 'Instances[0].InstanceId') @@ -65,7 +66,7 @@ cleanup() { # ---------------------------------------------------------------------------------------------------------------- # DELETE INSTANCE - rm -f user_data.sh + rm -f user_data*.sh instance_ids=$(aws ec2 describe-instances --filters "Name=tag:Name,Values=${name}-ec2-instance" \ --query "Reservations[*].Instances[*].InstanceId") for i in $instance_ids; do diff --git a/examples/command/portals/ai/amazon_ec2/health_corp/run_ockam.sh b/examples/command/portals/ai/amazon_ec2/health_corp/run_ockam.sh index 191e1971325..136f809613c 100755 --- a/examples/command/portals/ai/amazon_ec2/health_corp/run_ockam.sh +++ b/examples/command/portals/ai/amazon_ec2/health_corp/run_ockam.sh @@ -7,6 +7,7 @@ sudo -u ec2-user bash << 'EOS' set -ex # Install Ockam Command +export OCKAM_VERSION="$OCKAM_VERSION" curl --proto '=https' --tlsv1.2 -sSfL https://install.command.ockam.io | bash source "$HOME/.ockam/env" diff --git a/examples/command/portals/ai/amazon_ec2/run.sh b/examples/command/portals/ai/amazon_ec2/run.sh index 66f317f12c0..402f81301ca 100755 --- a/examples/command/portals/ai/amazon_ec2/run.sh +++ b/examples/command/portals/ai/amazon_ec2/run.sh @@ -44,6 +44,10 @@ run() { health_corp_ticket=$(ockam project ticket --usage-count 1 --expires-in 60m \ --attribute "ai-inlet=true") + if [[ -n "$OCKAM_VERSION" ]]; then + export OCKAM_VERSION="v${OCKAM_VERSION}"; + fi + # Invoke `ai_corp/run.sh` in the directory that has ai_corp's configuration. Pass the above # enrollment ticket as the first argument to run.sh script. Read ai_corp/run.sh to understand the parts # that are provisioned in ai_corp's virtual private cloud. diff --git a/examples/command/portals/apis/nodejs/amazon_ec2/aws_cli/monitoring_corp/run.sh b/examples/command/portals/apis/nodejs/amazon_ec2/aws_cli/monitoring_corp/run.sh index 9d1a7ca1295..beab8feec33 100755 --- a/examples/command/portals/apis/nodejs/amazon_ec2/aws_cli/monitoring_corp/run.sh +++ b/examples/command/portals/apis/nodejs/amazon_ec2/aws_cli/monitoring_corp/run.sh @@ -44,14 +44,14 @@ run() { aws ec2 create-key-pair --key-name "${name}-key" --query 'KeyMaterial' > key.pem chmod 400 key.pem - sed "s/\$ENROLLMENT_TICKET/${enrollment_ticket}/g" run_ockam.sh > user_data.sh + sed "s/\$ENROLLMENT_TICKET/${enrollment_ticket}/g" run_ockam.sh > user_data1.sh + sed "s/\$OCKAM_VERSION/${OCKAM_VERSION}/g" user_data1.sh > user_data.sh instance_id=$(aws ec2 run-instances --image-id "$ami_id" --instance-type t2.micro \ --subnet-id "$subnet_id" --security-group-ids "$sg_id" \ --key-name "${name}-key" --user-data file://user_data.sh --query 'Instances[0].InstanceId') aws ec2 create-tags --resources "$instance_id" --tags "Key=Name,Value=${name}-ec2-instance" aws ec2 wait instance-running --instance-ids "$instance_id" ip=$(aws ec2 describe-instances --instance-ids "$instance_id" --query 'Reservations[0].Instances[0].PublicIpAddress') - rm -f user_data.sh until scp -o StrictHostKeyChecking=no -i ./key.pem ./api.js "ec2-user@$ip:api.js"; do sleep 10; done ssh -o StrictHostKeyChecking=no -i ./key.pem "ec2-user@$ip" \ @@ -68,7 +68,7 @@ cleanup() { # ---------------------------------------------------------------------------------------------------------------- # DELETE INSTANCE - rm -f user_data.sh + rm -f user_data*.sh instance_ids=$(aws ec2 describe-instances --filters "Name=tag:Name,Values=${name}-ec2-instance" \ --query "Reservations[*].Instances[*].InstanceId") for i in $instance_ids; do diff --git a/examples/command/portals/apis/nodejs/amazon_ec2/aws_cli/monitoring_corp/run_ockam.sh b/examples/command/portals/apis/nodejs/amazon_ec2/aws_cli/monitoring_corp/run_ockam.sh index fe1373bb5e1..2193e849922 100644 --- a/examples/command/portals/apis/nodejs/amazon_ec2/aws_cli/monitoring_corp/run_ockam.sh +++ b/examples/command/portals/apis/nodejs/amazon_ec2/aws_cli/monitoring_corp/run_ockam.sh @@ -7,6 +7,7 @@ sudo -u ec2-user bash << 'EOS' set -ex # Install Ockam Command +export OCKAM_VERSION="$OCKAM_VERSION" curl --proto '=https' --tlsv1.2 -sSfL https://install.command.ockam.io | bash source "$HOME/.ockam/env" diff --git a/examples/command/portals/apis/nodejs/amazon_ec2/aws_cli/run.sh b/examples/command/portals/apis/nodejs/amazon_ec2/aws_cli/run.sh index 98d393536e6..7e203606278 100755 --- a/examples/command/portals/apis/nodejs/amazon_ec2/aws_cli/run.sh +++ b/examples/command/portals/apis/nodejs/amazon_ec2/aws_cli/run.sh @@ -44,6 +44,10 @@ run() { travel_app_corp_ticket=$(ockam project ticket --usage-count 1 --expires-in 60m \ --attribute "monitoring-api-inlet=true") + if [[ -n "$OCKAM_VERSION" ]]; then + export OCKAM_VERSION="v${OCKAM_VERSION}"; + fi + # Invoke `monitoring_corp/run.sh` in the directory that has monitoring_corp's configuration. Pass the above # enrollment ticket as the first argument to run.sh script. Read monitoring_corp/run.sh to understand the parts # that are provisioned in monitoring_corp's virtual private cloud. diff --git a/examples/command/portals/apis/nodejs/amazon_ec2/aws_cli/travel_app_corp/run.sh b/examples/command/portals/apis/nodejs/amazon_ec2/aws_cli/travel_app_corp/run.sh index 053945a22d0..ed71f877347 100755 --- a/examples/command/portals/apis/nodejs/amazon_ec2/aws_cli/travel_app_corp/run.sh +++ b/examples/command/portals/apis/nodejs/amazon_ec2/aws_cli/travel_app_corp/run.sh @@ -44,14 +44,14 @@ run() { aws ec2 create-key-pair --key-name "${name}-key" --query 'KeyMaterial' > key.pem chmod 400 key.pem - sed "s/\$ENROLLMENT_TICKET/${enrollment_ticket}/g" run_ockam.sh > user_data.sh + sed "s/\$ENROLLMENT_TICKET/${enrollment_ticket}/g" run_ockam.sh > user_data1.sh + sed "s/\$OCKAM_VERSION/${OCKAM_VERSION}/g" user_data1.sh > user_data.sh instance_id=$(aws ec2 run-instances --image-id "$ami_id" --instance-type t2.micro \ --subnet-id "$subnet_id" --security-group-ids "$sg_id" \ --key-name "${name}-key" --user-data file://user_data.sh --query 'Instances[0].InstanceId') aws ec2 create-tags --resources "$instance_id" --tags "Key=Name,Value=${name}-ec2-instance" aws ec2 wait instance-running --instance-ids "$instance_id" ip=$(aws ec2 describe-instances --instance-ids "$instance_id" --query 'Reservations[0].Instances[0].PublicIpAddress') - rm -f user_data.sh until scp -o StrictHostKeyChecking=no -i ./key.pem ./client.js "ec2-user@$ip:client.js"; do sleep 10; done ssh -o StrictHostKeyChecking=no -i ./key.pem "ec2-user@$ip" \ @@ -65,7 +65,7 @@ cleanup() { # ---------------------------------------------------------------------------------------------------------------- # DELETE INSTANCE - rm -f user_data.sh + rm -rf user_data*.sh instance_ids=$(aws ec2 describe-instances --filters "Name=tag:Name,Values=${name}-ec2-instance" \ --query "Reservations[*].Instances[*].InstanceId") for i in $instance_ids; do diff --git a/examples/command/portals/apis/nodejs/amazon_ec2/aws_cli/travel_app_corp/run_ockam.sh b/examples/command/portals/apis/nodejs/amazon_ec2/aws_cli/travel_app_corp/run_ockam.sh index db92e25e30e..f0e491a21f3 100755 --- a/examples/command/portals/apis/nodejs/amazon_ec2/aws_cli/travel_app_corp/run_ockam.sh +++ b/examples/command/portals/apis/nodejs/amazon_ec2/aws_cli/travel_app_corp/run_ockam.sh @@ -7,6 +7,7 @@ sudo -u ec2-user bash << 'EOS' set -ex # Install Ockam Command +export OCKAM_VERSION="$OCKAM_VERSION" curl --proto '=https' --tlsv1.2 -sSfL https://install.command.ockam.io | bash source "$HOME/.ockam/env" diff --git a/examples/command/portals/apis/python/amazon_ec2/aws_cli/monitoring_corp/run.sh b/examples/command/portals/apis/python/amazon_ec2/aws_cli/monitoring_corp/run.sh index d697552e52d..0c8b90cd87f 100755 --- a/examples/command/portals/apis/python/amazon_ec2/aws_cli/monitoring_corp/run.sh +++ b/examples/command/portals/apis/python/amazon_ec2/aws_cli/monitoring_corp/run.sh @@ -44,7 +44,8 @@ run() { aws ec2 create-key-pair --key-name "${name}-key" --query 'KeyMaterial' > key.pem chmod 400 key.pem - sed "s/\$ENROLLMENT_TICKET/${enrollment_ticket}/g" run_ockam.sh > user_data.sh + sed "s/\$ENROLLMENT_TICKET/${enrollment_ticket}/g" run_ockam.sh > user_data1.sh + sed "s/\$OCKAM_VERSION/${OCKAM_VERSION}/g" user_data1.sh > user_data.sh instance_id=$(aws ec2 run-instances --image-id "$ami_id" --instance-type t2.micro \ --subnet-id "$subnet_id" --security-group-ids "$sg_id" \ --key-name "${name}-key" --user-data file://user_data.sh --query 'Instances[0].InstanceId') diff --git a/examples/command/portals/apis/python/amazon_ec2/aws_cli/monitoring_corp/run_ockam.sh b/examples/command/portals/apis/python/amazon_ec2/aws_cli/monitoring_corp/run_ockam.sh index 4fe771c2e0c..ef67fb7904d 100644 --- a/examples/command/portals/apis/python/amazon_ec2/aws_cli/monitoring_corp/run_ockam.sh +++ b/examples/command/portals/apis/python/amazon_ec2/aws_cli/monitoring_corp/run_ockam.sh @@ -7,6 +7,7 @@ sudo -u ec2-user bash << 'EOS' set -ex # Install Ockam Command +export OCKAM_VERSION="$OCKAM_VERSION" curl --proto '=https' --tlsv1.2 -sSfL https://install.command.ockam.io | bash source "$HOME/.ockam/env" diff --git a/examples/command/portals/apis/python/amazon_ec2/aws_cli/run.sh b/examples/command/portals/apis/python/amazon_ec2/aws_cli/run.sh index 581fd021f26..d2d6ff259b5 100755 --- a/examples/command/portals/apis/python/amazon_ec2/aws_cli/run.sh +++ b/examples/command/portals/apis/python/amazon_ec2/aws_cli/run.sh @@ -45,6 +45,10 @@ run() { travel_app_corp_ticket=$(ockam project ticket --usage-count 1 --expires-in 60m \ --attribute "monitoring-api-inlet=true") + if [[ -n "$OCKAM_VERSION" ]]; then + export OCKAM_VERSION="v${OCKAM_VERSION}"; + fi + # Invoke `monitoring_corp/run.sh` in the directory that has monitoring_corp's configuration. Pass the above # enrollment ticket as the first argument to run.sh script. Read monitoring_corp/run.sh to understand the parts # that are provisioned in monitoring_corp's virtual private cloud. diff --git a/examples/command/portals/apis/python/amazon_ec2/aws_cli/travel_app_corp/run.sh b/examples/command/portals/apis/python/amazon_ec2/aws_cli/travel_app_corp/run.sh index 053d3fdd9dd..bb364a5b02e 100755 --- a/examples/command/portals/apis/python/amazon_ec2/aws_cli/travel_app_corp/run.sh +++ b/examples/command/portals/apis/python/amazon_ec2/aws_cli/travel_app_corp/run.sh @@ -44,14 +44,14 @@ run() { aws ec2 create-key-pair --key-name "${name}-key" --query 'KeyMaterial' > key.pem chmod 400 key.pem - sed "s/\$ENROLLMENT_TICKET/${enrollment_ticket}/g" run_ockam.sh > user_data.sh + sed "s/\$ENROLLMENT_TICKET/${enrollment_ticket}/g" run_ockam.sh > user_data1.sh + sed "s/\$OCKAM_VERSION/${OCKAM_VERSION}/g" user_data1.sh > user_data.sh instance_id=$(aws ec2 run-instances --image-id "$ami_id" --instance-type t2.micro \ --subnet-id "$subnet_id" --security-group-ids "$sg_id" \ --key-name "${name}-key" --user-data file://user_data.sh --query 'Instances[0].InstanceId') aws ec2 create-tags --resources "$instance_id" --tags "Key=Name,Value=${name}-ec2-instance" aws ec2 wait instance-running --instance-ids "$instance_id" ip=$(aws ec2 describe-instances --instance-ids "$instance_id" --query 'Reservations[0].Instances[0].PublicIpAddress') - rm -f user_data.sh until scp -o StrictHostKeyChecking=no -i ./key.pem ./client.py "ec2-user@$ip:client.py"; do sleep 10; done ssh -o StrictHostKeyChecking=no -i ./key.pem "ec2-user@$ip" \ @@ -68,7 +68,7 @@ cleanup() { # ---------------------------------------------------------------------------------------------------------------- # DELETE INSTANCE - rm -f user_data.sh + rm -rf user_data*.sh instance_ids=$(aws ec2 describe-instances --filters "Name=tag:Name,Values=${name}-ec2-instance" \ --query "Reservations[*].Instances[*].InstanceId") for i in $instance_ids; do diff --git a/examples/command/portals/apis/python/amazon_ec2/aws_cli/travel_app_corp/run_ockam.sh b/examples/command/portals/apis/python/amazon_ec2/aws_cli/travel_app_corp/run_ockam.sh index dc76776dc3a..93b59017a71 100755 --- a/examples/command/portals/apis/python/amazon_ec2/aws_cli/travel_app_corp/run_ockam.sh +++ b/examples/command/portals/apis/python/amazon_ec2/aws_cli/travel_app_corp/run_ockam.sh @@ -7,6 +7,7 @@ sudo -u ec2-user bash << 'EOS' set -ex # Install Ockam Command +export OCKAM_VERSION="$OCKAM_VERSION" curl --proto '=https' --tlsv1.2 -sSfL https://install.command.ockam.io | bash source "$HOME/.ockam/env" diff --git a/examples/command/portals/coderepos/gitlab/amazon_ec2/aws_cli/analysis_corp/run.sh b/examples/command/portals/coderepos/gitlab/amazon_ec2/aws_cli/analysis_corp/run.sh index 0b081800ee4..58e9d0cf771 100755 --- a/examples/command/portals/coderepos/gitlab/amazon_ec2/aws_cli/analysis_corp/run.sh +++ b/examples/command/portals/coderepos/gitlab/amazon_ec2/aws_cli/analysis_corp/run.sh @@ -33,7 +33,7 @@ run() { sg_id=$(aws ec2 create-security-group --group-name "${name}-sg" --vpc-id "$vpc_id" --query 'GroupId' \ --description "Allow TCP egress and Postgres ingress") aws ec2 authorize-security-group-egress --group-id "$sg_id" --cidr 0.0.0.0/0 --protocol tcp --port 0-65535 - aws ec2 authorize-security-group-ingress --group-id "$sg_id" --cidr "${my_ip}/32" --protocol tcp --port 22 + aws ec2 authorize-security-group-ingress --group-id "$sg_id" --cidr "0.0.0.0/0" --protocol tcp --port 22 # ---------------------------------------------------------------------------------------------------------------- # CREATE INSTANCE @@ -45,15 +45,15 @@ run() { aws ec2 create-key-pair --key-name "${name}-key" --query 'KeyMaterial' > key.pem chmod 400 key.pem - sed "s/\$ENROLLMENT_TICKET/${enrollment_ticket}/g" run_ockam.sh > run_ockam_temp.sh - cat run_repoaccess.sh run_ockam_temp.sh > user_data.sh + sed "s/\$ENROLLMENT_TICKET/${enrollment_ticket}/g" run_ockam.sh > user_data1.sh + sed "s/\$OCKAM_VERSION/${OCKAM_VERSION}/g" user_data1.sh > user_data2.sh + cat run_repoaccess.sh user_data2.sh > user_data.sh instance_id=$(aws ec2 run-instances --image-id "$ami_id" --instance-type c5n.large \ --subnet-id "$subnet_id" --security-group-ids "$sg_id" \ --key-name "${name}-key" --user-data file://user_data.sh --query 'Instances[0].InstanceId') aws ec2 create-tags --resources "$instance_id" --tags "Key=Name,Value=${name}-ec2-instance" aws ec2 wait instance-running --instance-ids "$instance_id" ip=$(aws ec2 describe-instances --instance-ids "$instance_id" --query 'Reservations[0].Instances[0].PublicIpAddress') - rm -f run_ockam_temp.sh user_data.sh until scp -o StrictHostKeyChecking=no -i ./key.pem ./app.js "ec2-user@$ip:app.js"; do sleep 10; done until scp -o StrictHostKeyChecking=no -i ./key.pem ../bank_corp/gitlab_rsa "ec2-user@$ip:gitlab_rsa"; do sleep 10; done @@ -70,7 +70,8 @@ cleanup() { # ---------------------------------------------------------------------------------------------------------------- # DELETE INSTANCE - rm -f run_ockam_temp.sh user_data.sh + rm -rf user_data*.sh + rm -rf run_repoaccess.sh instance_ids=$(aws ec2 describe-instances --filters "Name=tag:Name,Values=${name}-ec2-instance" \ --query "Reservations[*].Instances[*].InstanceId") for i in $instance_ids; do diff --git a/examples/command/portals/coderepos/gitlab/amazon_ec2/aws_cli/analysis_corp/run_ockam.sh b/examples/command/portals/coderepos/gitlab/amazon_ec2/aws_cli/analysis_corp/run_ockam.sh index b246e9e7d7d..ae2f5d53cb4 100755 --- a/examples/command/portals/coderepos/gitlab/amazon_ec2/aws_cli/analysis_corp/run_ockam.sh +++ b/examples/command/portals/coderepos/gitlab/amazon_ec2/aws_cli/analysis_corp/run_ockam.sh @@ -7,6 +7,7 @@ sudo -u ec2-user bash << 'EOS' set -ex # Install Ockam Command +export OCKAM_VERSION="$OCKAM_VERSION" curl --proto '=https' --tlsv1.2 -sSfL https://install.command.ockam.io | bash source "$HOME/.ockam/env" diff --git a/examples/command/portals/coderepos/gitlab/amazon_ec2/aws_cli/bank_corp/run.sh b/examples/command/portals/coderepos/gitlab/amazon_ec2/aws_cli/bank_corp/run.sh index 4c7ef295c52..2c9ba14e313 100755 --- a/examples/command/portals/coderepos/gitlab/amazon_ec2/aws_cli/bank_corp/run.sh +++ b/examples/command/portals/coderepos/gitlab/amazon_ec2/aws_cli/bank_corp/run.sh @@ -39,8 +39,8 @@ run() { sg_id=$(aws ec2 create-security-group --group-name "${name}-sg" --vpc-id "$vpc_id" --query 'GroupId' \ --description "Allow TCP egress and gitlab ingress") aws ec2 authorize-security-group-egress --group-id "$sg_id" --cidr 0.0.0.0/0 --protocol tcp --port 0-65535 - aws ec2 authorize-security-group-ingress --group-id "$sg_id" --cidr "${my_ip}/32" --protocol tcp --port 22 - aws ec2 authorize-security-group-ingress --group-id "$sg_id" --cidr "${my_ip}/32" --protocol tcp --port 80 + aws ec2 authorize-security-group-ingress --group-id "$sg_id" --cidr "0.0.0.0/0" --protocol tcp --port 22 + aws ec2 authorize-security-group-ingress --group-id "$sg_id" --cidr "0.0.0.0/0" --protocol tcp --port 80 # ---------------------------------------------------------------------------------------------------------------- # CREATE INSTANCE @@ -54,10 +54,12 @@ run() { aws ec2 create-key-pair --key-name "${name}-key" --query 'KeyMaterial' > key.pem chmod 400 key.pem - sed "s/\$ENROLLMENT_TICKET/${enrollment_ticket}/g" run_ockam.sh > run_ockam_temp.sh + sed "s/\$ENROLLMENT_TICKET/${enrollment_ticket}/g" run_ockam.sh > user_data1.sh + sed "s/\$OCKAM_VERSION/${OCKAM_VERSION}/g" user_data1.sh > user_data2.sh sed "s|PUBLIC_KEY=\$SSH_PUBLIC_KEY|PUBLIC_KEY='$SSH_PUBLIC_KEY'|g" run_gitlab.sh > run_gitlab_temp.sh - cat run_gitlab_temp.sh run_ockam_temp.sh > user_data.sh + cat run_gitlab_temp.sh user_data2.sh > user_data.sh + instance_id=$(aws ec2 run-instances --image-id "$ami_id" --instance-type c5n.large \ --subnet-id "$subnet1_id" --security-group-ids "$sg_id" \ --key-name "${name}-key" --user-data file://user_data.sh --query 'Instances[0].InstanceId') @@ -66,7 +68,6 @@ run() { ip=$(aws ec2 describe-instances --instance-ids "$instance_id" --query 'Reservations[0].Instances[0].PublicIpAddress') sleep 180 check_gitlab_availability "$ip" - rm -f user_data.sh run_gitlab_temp.sh run_ockam_temp.sh } check_gitlab_availability() { @@ -100,7 +101,8 @@ cleanup() { # ---------------------------------------------------------------------------------------------------------------- # DELETE INSTANCE - rm -f user_data.sh run_gitlab_temp.sh run_ockam_temp.sh + rm -rf user_data*.sh + rm -rf run_gitlab_temp.sh rm -f gitlab_rsa gitlab_rsa.pub instance_ids=$(aws ec2 describe-instances --filters "Name=tag:Name,Values=${name}-gitlab-ec2" \ --query "Reservations[*].Instances[*].InstanceId") diff --git a/examples/command/portals/coderepos/gitlab/amazon_ec2/aws_cli/bank_corp/run_gitlab.sh b/examples/command/portals/coderepos/gitlab/amazon_ec2/aws_cli/bank_corp/run_gitlab.sh index a8c56fff432..ca9ce38c4ee 100644 --- a/examples/command/portals/coderepos/gitlab/amazon_ec2/aws_cli/bank_corp/run_gitlab.sh +++ b/examples/command/portals/coderepos/gitlab/amazon_ec2/aws_cli/bank_corp/run_gitlab.sh @@ -98,4 +98,3 @@ curl -X POST -H "Content-Type: application/json" -H "Authorization: Bearer $ACCE echo "SSH key added successfully." echo "Setup complete" - diff --git a/examples/command/portals/coderepos/gitlab/amazon_ec2/aws_cli/bank_corp/run_ockam.sh b/examples/command/portals/coderepos/gitlab/amazon_ec2/aws_cli/bank_corp/run_ockam.sh index cd140a06f58..ed40d360c5e 100644 --- a/examples/command/portals/coderepos/gitlab/amazon_ec2/aws_cli/bank_corp/run_ockam.sh +++ b/examples/command/portals/coderepos/gitlab/amazon_ec2/aws_cli/bank_corp/run_ockam.sh @@ -7,6 +7,7 @@ sudo -u ec2-user bash << 'EOS' set -ex # Install Ockam Command +export OCKAM_VERSION="$OCKAM_VERSION" curl --proto '=https' --tlsv1.2 -sSfL https://install.command.ockam.io | bash source "$HOME/.ockam/env" diff --git a/examples/command/portals/coderepos/gitlab/amazon_ec2/aws_cli/run.sh b/examples/command/portals/coderepos/gitlab/amazon_ec2/aws_cli/run.sh index a0d7a8eab9a..90e9575f965 100755 --- a/examples/command/portals/coderepos/gitlab/amazon_ec2/aws_cli/run.sh +++ b/examples/command/portals/coderepos/gitlab/amazon_ec2/aws_cli/run.sh @@ -44,6 +44,10 @@ run() { analysis_corp_ticket=$(ockam project ticket --usage-count 1 --expires-in 60m \ --attribute "gitlab-inlet=true") + if [[ -n "$OCKAM_VERSION" ]]; then + export OCKAM_VERSION="v${OCKAM_VERSION}"; + fi + # Invoke `bank_corp/run.sh` in the directory that has bank_corp's configuration. Pass the above enrollment ticket # as the first argument to run.sh script. Read bank_corp/run.sh to understand the parts that are provisioned in # bank_corp's virtual private cloud. diff --git a/examples/command/portals/databases/influxdb/amazon_timestream/aws_cli/datastream_corp/run.sh b/examples/command/portals/databases/influxdb/amazon_timestream/aws_cli/datastream_corp/run.sh index 798775b27be..256667c84fa 100755 --- a/examples/command/portals/databases/influxdb/amazon_timestream/aws_cli/datastream_corp/run.sh +++ b/examples/command/portals/databases/influxdb/amazon_timestream/aws_cli/datastream_corp/run.sh @@ -32,8 +32,7 @@ run() { aws ec2 authorize-security-group-egress --group-id "$sg_id" --cidr 0.0.0.0/0 --protocol tcp --port 0-65535 # Allow SSH from the machine where this script is running, so we can provision instances. - my_ip=$(curl -s https://checkip.amazonaws.com) - aws ec2 authorize-security-group-ingress --group-id "$sg_id" --cidr "${my_ip}/32" --protocol tcp --port 22 + aws ec2 authorize-security-group-ingress --group-id "$sg_id" --cidr "0.0.0.0/0" --protocol tcp --port 22 # ---------------------------------------------------------------------------------------------------------------- # CREATE INSTANCE @@ -45,7 +44,8 @@ run() { aws ec2 create-key-pair --key-name "${name}-key" --query 'KeyMaterial' > key.pem chmod 400 key.pem - sed "s/\$ENROLLMENT_TICKET/${enrollment_ticket}/g" run_ockam.sh > user_data.sh + sed "s/\$ENROLLMENT_TICKET/${enrollment_ticket}/g" run_ockam.sh > user_data1.sh + sed "s/\$OCKAM_VERSION/${OCKAM_VERSION}/g" user_data1.sh > user_data.sh instance_id=$(aws ec2 run-instances --image-id "$ami_id" --instance-type c5n.large \ --subnet-id "$subnet_id" --security-group-ids "$sg_id" \ --key-name "${name}-key" --user-data file://user_data.sh --query 'Instances[0].InstanceId') diff --git a/examples/command/portals/databases/influxdb/amazon_timestream/aws_cli/datastream_corp/run_ockam.sh b/examples/command/portals/databases/influxdb/amazon_timestream/aws_cli/datastream_corp/run_ockam.sh index 087005c9fa6..447ac42e233 100755 --- a/examples/command/portals/databases/influxdb/amazon_timestream/aws_cli/datastream_corp/run_ockam.sh +++ b/examples/command/portals/databases/influxdb/amazon_timestream/aws_cli/datastream_corp/run_ockam.sh @@ -7,6 +7,7 @@ sudo -u ec2-user bash << 'EOS' set -ex # Install Ockam Command +export OCKAM_VERSION="$OCKAM_VERSION" curl --proto '=https' --tlsv1.2 -sSfL https://install.command.ockam.io | bash source "$HOME/.ockam/env" diff --git a/examples/command/portals/databases/influxdb/amazon_timestream/aws_cli/metrics_corp/run.sh b/examples/command/portals/databases/influxdb/amazon_timestream/aws_cli/metrics_corp/run.sh index 006c93fc718..4e7b3d83414 100755 --- a/examples/command/portals/databases/influxdb/amazon_timestream/aws_cli/metrics_corp/run.sh +++ b/examples/command/portals/databases/influxdb/amazon_timestream/aws_cli/metrics_corp/run.sh @@ -39,7 +39,7 @@ run() { # Allow SSH from the machine where this script is running, so we can provision instances. my_ip=$(curl -s https://checkip.amazonaws.com) - aws ec2 authorize-security-group-ingress --group-id "$sg_id" --cidr "${my_ip}/32" --protocol tcp --port 22 + aws ec2 authorize-security-group-ingress --group-id "$sg_id" --cidr "0.0.0.0/0" --protocol tcp --port 22 # ---------------------------------------------------------------------------------------------------------------- # CREATE INFLUXDB DATABASE @@ -73,14 +73,14 @@ run() { chmod 400 key.pem sed "s/\$ENROLLMENT_TICKET/${enrollment_ticket}/g" run_ockam.sh > user_data1.sh - sed "s/\$INFLUXDB_ADDRESS/${db_endpoint}/g" user_data1.sh > user_data.sh + sed "s/\$OCKAM_VERSION/${OCKAM_VERSION}/g" user_data1.sh > user_data2.sh + sed "s/\$INFLUXDB_ADDRESS/${db_endpoint}/g" user_data2.sh > user_data.sh instance_id=$(aws ec2 run-instances --image-id "$ami_id" --instance-type c5n.large \ --subnet-id "$subnet_id" --security-group-ids "$sg_id" \ --key-name "${name}-key" --user-data file://user_data.sh --query 'Instances[0].InstanceId') aws ec2 create-tags --resources "$instance_id" --tags "Key=Name,Value=${name}-ec2-instance" aws ec2 wait instance-running --instance-ids "$instance_id" ip=$(aws ec2 describe-instances --instance-ids "$instance_id" --query 'Reservations[0].Instances[0].PublicIpAddress') - rm -f user_data.sh user_data1.sh scp -o StrictHostKeyChecking=no -i ./key.pem "ec2-user@$ip:token.txt" ../datastream_corp/token.txt } @@ -90,7 +90,7 @@ cleanup() { # ---------------------------------------------------------------------------------------------------------------- # DELETE INSTANCE - rm -f user_data.sh user_data1.sh + rm -f user_data*.sh instance_ids=$(aws ec2 describe-instances --filters "Name=tag:Name,Values=${name}-ec2-instance" \ --query "Reservations[*].Instances[*].InstanceId") for i in $instance_ids; do diff --git a/examples/command/portals/databases/influxdb/amazon_timestream/aws_cli/metrics_corp/run_ockam.sh b/examples/command/portals/databases/influxdb/amazon_timestream/aws_cli/metrics_corp/run_ockam.sh index 034dd495150..ed44ec92f6b 100644 --- a/examples/command/portals/databases/influxdb/amazon_timestream/aws_cli/metrics_corp/run_ockam.sh +++ b/examples/command/portals/databases/influxdb/amazon_timestream/aws_cli/metrics_corp/run_ockam.sh @@ -22,6 +22,7 @@ while ! ./influx bucket list; do sleep 10; done ./influx auth create --all-access --json | jq -r .token > token.txt # Install Ockam Command +export OCKAM_VERSION="$OCKAM_VERSION" curl --proto '=https' --tlsv1.2 -sSfL https://install.command.ockam.io | bash source "$HOME/.ockam/env" diff --git a/examples/command/portals/databases/influxdb/amazon_timestream/aws_cli/run.sh b/examples/command/portals/databases/influxdb/amazon_timestream/aws_cli/run.sh index fcde55699b8..6f087d743ec 100755 --- a/examples/command/portals/databases/influxdb/amazon_timestream/aws_cli/run.sh +++ b/examples/command/portals/databases/influxdb/amazon_timestream/aws_cli/run.sh @@ -45,6 +45,10 @@ run() { datastream_corp_ticket=$(ockam project ticket --usage-count 1 --expires-in 60m \ --attribute "influxdb-inlet=true") + if [[ -n "$OCKAM_VERSION" ]]; then + export OCKAM_VERSION="v${OCKAM_VERSION}"; + fi + # Invoke `metrics_corp/run.sh` in the directory that has metrics_corp's configuration. Pass the above enrollment ticket # as the first argument to run.sh script. Read metrics_corp/run.sh to understand the parts that are provisioned in # metrics_corp's virtual private cloud. diff --git a/examples/command/portals/databases/mongodb/amazon_vpc/analysis_corp/app.js b/examples/command/portals/databases/mongodb/amazon_vpc/analysis_corp/app.js index dd975c5f34b..4087274939a 100644 --- a/examples/command/portals/databases/mongodb/amazon_vpc/analysis_corp/app.js +++ b/examples/command/portals/databases/mongodb/amazon_vpc/analysis_corp/app.js @@ -10,7 +10,7 @@ const uri = "mongodb://127.0.0.1:17017/mydb" // // Since all the containers may take a few seconds to start up. // We'll attempt to connect in a loop once every 10 seconds by default. -async function connect(attempts = 100, waitTimeBetweenAttempts = 10000) { +async function connect(attempts = 5, waitTimeBetweenAttempts = 10000) { while (attempts--) { const client = new MongoClient(uri); try { diff --git a/examples/command/portals/databases/mongodb/amazon_vpc/analysis_corp/run.sh b/examples/command/portals/databases/mongodb/amazon_vpc/analysis_corp/run.sh index eff5dc63a0b..82723a7d914 100755 --- a/examples/command/portals/databases/mongodb/amazon_vpc/analysis_corp/run.sh +++ b/examples/command/portals/databases/mongodb/amazon_vpc/analysis_corp/run.sh @@ -44,14 +44,14 @@ run() { aws ec2 create-key-pair --key-name "${name}-key" --query 'KeyMaterial' > key.pem chmod 400 key.pem - sed "s/\$ENROLLMENT_TICKET/${enrollment_ticket}/g" run_ockam.sh > user_data.sh + sed "s/\$ENROLLMENT_TICKET/${enrollment_ticket}/g" run_ockam.sh > user_data1.sh + sed "s/\$OCKAM_VERSION/${OCKAM_VERSION}/g" user_data1.sh > user_data.sh instance_id=$(aws ec2 run-instances --image-id "$ami_id" --instance-type c5n.large \ --subnet-id "$subnet_id" --security-group-ids "$sg_id" \ --key-name "${name}-key" --user-data file://user_data.sh --query 'Instances[0].InstanceId') aws ec2 create-tags --resources "$instance_id" --tags "Key=Name,Value=${name}-ec2-instance" aws ec2 wait instance-running --instance-ids "$instance_id" ip=$(aws ec2 describe-instances --instance-ids "$instance_id" --query 'Reservations[0].Instances[0].PublicIpAddress') - rm -f user_data.sh until scp -o StrictHostKeyChecking=no -i ./key.pem ./app.js "ec2-user@$ip:app.js"; do sleep 10; done ssh -o StrictHostKeyChecking=no -i ./key.pem "ec2-user@$ip" \ @@ -66,7 +66,7 @@ cleanup() { # ---------------------------------------------------------------------------------------------------------------- # DELETE INSTANCE - rm -f user_data.sh + rm -rf user_data*.sh instance_ids=$(aws ec2 describe-instances --filters "Name=tag:Name,Values=${name}-ec2-instance" \ --query "Reservations[*].Instances[*].InstanceId") for i in $instance_ids; do diff --git a/examples/command/portals/databases/mongodb/amazon_vpc/analysis_corp/run_ockam.sh b/examples/command/portals/databases/mongodb/amazon_vpc/analysis_corp/run_ockam.sh index 29e39b8ff7b..c4b2fc0b978 100755 --- a/examples/command/portals/databases/mongodb/amazon_vpc/analysis_corp/run_ockam.sh +++ b/examples/command/portals/databases/mongodb/amazon_vpc/analysis_corp/run_ockam.sh @@ -7,6 +7,7 @@ sudo -u ec2-user bash << 'EOS' set -ex # Install Ockam Command +export OCKAM_VERSION="$OCKAM_VERSION" curl --proto '=https' --tlsv1.2 -sSfL https://install.command.ockam.io | bash source "$HOME/.ockam/env" diff --git a/examples/command/portals/databases/mongodb/amazon_vpc/bank_corp/run.sh b/examples/command/portals/databases/mongodb/amazon_vpc/bank_corp/run.sh index d050107d5f9..fcf024d4fec 100755 --- a/examples/command/portals/databases/mongodb/amazon_vpc/bank_corp/run.sh +++ b/examples/command/portals/databases/mongodb/amazon_vpc/bank_corp/run.sh @@ -41,20 +41,20 @@ run() { --filters "Name=name,Values=al2023-ami-2023*" "Name=architecture,Values=x86_64" \ "Name=virtualization-type,Values=hvm" "Name=root-device-type,Values=ebs" ) - sed "s/\$ENROLLMENT_TICKET/${enrollment_ticket}/g" run_ockam.sh > user_data.sh + sed "s/\$ENROLLMENT_TICKET/${enrollment_ticket}/g" run_ockam.sh > user_data1.sh + sed "s/\$OCKAM_VERSION/${OCKAM_VERSION}/g" user_data1.sh > user_data.sh instance_id=$(aws ec2 run-instances --image-id "$ami_id" --instance-type c5n.large \ --subnet-id "$subnet_id" --security-group-ids "$sg_id" \ --user-data file://user_data.sh --query 'Instances[0].InstanceId') aws ec2 create-tags --resources "$instance_id" --tags "Key=Name,Value=${name}-ec2-instance" aws ec2 wait instance-running --instance-ids "$instance_id" - rm -f user_data.sh } cleanup() { # ---------------------------------------------------------------------------------------------------------------- # DELETE INSTANCE - rm -f user_data.sh + rm -rf user_data*.sh instance_ids=$(aws ec2 describe-instances --filters "Name=tag:Name,Values=${name}-ec2-instance" \ --query "Reservations[*].Instances[*].InstanceId") for i in $instance_ids; do diff --git a/examples/command/portals/databases/mongodb/amazon_vpc/bank_corp/run_ockam.sh b/examples/command/portals/databases/mongodb/amazon_vpc/bank_corp/run_ockam.sh index 6392097dac0..230552caf76 100755 --- a/examples/command/portals/databases/mongodb/amazon_vpc/bank_corp/run_ockam.sh +++ b/examples/command/portals/databases/mongodb/amazon_vpc/bank_corp/run_ockam.sh @@ -21,6 +21,7 @@ sudo systemctl restart mongod # Install Ockam Command +export OCKAM_VERSION="$OCKAM_VERSION" curl --proto '=https' --tlsv1.2 -sSfL https://install.command.ockam.io | bash source "$HOME/.ockam/env" diff --git a/examples/command/portals/databases/mongodb/amazon_vpc/run.sh b/examples/command/portals/databases/mongodb/amazon_vpc/run.sh index 864bb53709c..a9b3a255e43 100755 --- a/examples/command/portals/databases/mongodb/amazon_vpc/run.sh +++ b/examples/command/portals/databases/mongodb/amazon_vpc/run.sh @@ -47,6 +47,10 @@ run() { analysis_corp_ticket=$(ockam project ticket --usage-count 1 --expires-in 10m \ --attribute "mongodb-inlet=true") + if [[ -n "$OCKAM_VERSION" ]]; then + export OCKAM_VERSION="v${OCKAM_VERSION}"; + fi + # Invoke `bank_corp/run.sh` in the directory that has bank_corp's configuration. Pass the above enrollment ticket # as the first argument to run.sh script. Read bank_corp/run.sh to understand the parts that are provisioned in # bank_corp's virtual private cloud. diff --git a/examples/command/portals/databases/mongodb/docker/analysis_corp/app.js b/examples/command/portals/databases/mongodb/docker/analysis_corp/app.js index 8d63418436c..44b9433febb 100644 --- a/examples/command/portals/databases/mongodb/docker/analysis_corp/app.js +++ b/examples/command/portals/databases/mongodb/docker/analysis_corp/app.js @@ -26,8 +26,8 @@ async function connect(attempts = 100, waitTimeBetweenAttempts = 10000) { } async function run() { - const client = await connect(); - try { + const client = await connect(); + try { const database = client.db('sample'); const users = database.collection('users'); diff --git a/examples/command/portals/databases/mongodb/docker/analysis_corp/docker-compose.yml b/examples/command/portals/databases/mongodb/docker/analysis_corp/docker-compose.yml index 63c1187a8ac..4c69634063f 100644 --- a/examples/command/portals/databases/mongodb/docker/analysis_corp/docker-compose.yml +++ b/examples/command/portals/databases/mongodb/docker/analysis_corp/docker-compose.yml @@ -14,6 +14,8 @@ services: build: context: . dockerfile: ../ockam.dockerfile + args: + OCKAM_VERSION: ${OCKAM_VERSION:-latest} environment: ENROLLMENT_TICKET: ${ENROLLMENT_TICKET:-} OCKAM_DEVELOPER: ${OCKAM_DEVELOPER:-false} @@ -26,6 +28,7 @@ services: # the app is doing. app: depends_on: [ockam] + container_name: analysis_corp-app build: context: . dockerfile: app.dockerfile diff --git a/examples/command/portals/databases/mongodb/docker/bank_corp/docker-compose.yml b/examples/command/portals/databases/mongodb/docker/bank_corp/docker-compose.yml index 0f64edeaf30..ec8475fe42d 100644 --- a/examples/command/portals/databases/mongodb/docker/bank_corp/docker-compose.yml +++ b/examples/command/portals/databases/mongodb/docker/bank_corp/docker-compose.yml @@ -21,6 +21,8 @@ services: build: context: . dockerfile: ../ockam.dockerfile + args: + OCKAM_VERSION: ${OCKAM_VERSION:-latest} environment: ENROLLMENT_TICKET: ${ENROLLMENT_TICKET:-} OCKAM_DEVELOPER: ${OCKAM_DEVELOPER:-false} diff --git a/examples/command/portals/databases/mongodb/docker/ockam.dockerfile b/examples/command/portals/databases/mongodb/docker/ockam.dockerfile index 36ed28007d9..546ea06c6a4 100644 --- a/examples/command/portals/databases/mongodb/docker/ockam.dockerfile +++ b/examples/command/portals/databases/mongodb/docker/ockam.dockerfile @@ -9,7 +9,9 @@ # Read bank_corp/run_ockam.sh and analysis_corp/run_ockam.sh to understand # how each node is set up. -FROM ghcr.io/build-trust/ockam as builder +ARG OCKAM_VERSION=latest + +FROM ghcr.io/build-trust/ockam:${OCKAM_VERSION} as builder FROM cgr.dev/chainguard/bash COPY --from=builder /ockam /usr/local/bin/ockam diff --git a/examples/command/portals/databases/mongodb/docker/run.sh b/examples/command/portals/databases/mongodb/docker/run.sh index c631583dcd3..c261d678fff 100755 --- a/examples/command/portals/databases/mongodb/docker/run.sh +++ b/examples/command/portals/databases/mongodb/docker/run.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -set -e +set -ex # This script, `./run.sh ...` is invoked on a developer’s work machine. # diff --git a/examples/command/portals/databases/mongodb/kubernetes/run.sh b/examples/command/portals/databases/mongodb/kubernetes/run.sh index f87f73c4cdb..42b55414ad8 100755 --- a/examples/command/portals/databases/mongodb/kubernetes/run.sh +++ b/examples/command/portals/databases/mongodb/kubernetes/run.sh @@ -97,11 +97,15 @@ run() { build_and_load_docker_image() { tag="$1"; dockerfile="$2"; context="$3"; cluster="$4" + if [[ -z $OCKAM_VERSION ]]; then + export OCKAM_VERSION="latest" + fi + # Use --load option only if docker buildx is available. if docker buildx ls &>/dev/null; then - docker build --load --file "$dockerfile" --tag "$tag" "$context" + docker build --build-arg OCKAM_VERSION="$OCKAM_VERSION" --load --file "$dockerfile" --tag "$tag" "$context" else - docker build --file "$dockerfile" --tag "$tag" "$context" + docker build --build-arg OCKAM_VERSION="$OCKAM_VERSION" --file "$dockerfile" --tag "$tag" "$context" fi kind load docker-image "$tag" --name "$cluster" diff --git a/examples/command/portals/databases/postgres/amazon_aurora/aws_cli/analysis_corp/app.js b/examples/command/portals/databases/postgres/amazon_aurora/aws_cli/analysis_corp/app.js index 83a11e99853..a7cc1773714 100644 --- a/examples/command/portals/databases/postgres/amazon_aurora/aws_cli/analysis_corp/app.js +++ b/examples/command/portals/databases/postgres/amazon_aurora/aws_cli/analysis_corp/app.js @@ -62,8 +62,8 @@ async function run() { console.log( "\nThe example run was successful 🥳.\n" + - "\nThe app connected with the database through an encrypted portal." + - "\nCreated a table, inserted some data, and querried it back.\n", + "\nThe app connected with the database through an encrypted portal." + + "\nCreated a table, inserted some data, and querried it back.\n", ); } catch (err) { console.error("Error:", err.message); diff --git a/examples/command/portals/databases/postgres/amazon_aurora/aws_cli/analysis_corp/run.sh b/examples/command/portals/databases/postgres/amazon_aurora/aws_cli/analysis_corp/run.sh index f10d3526120..56ce00eed47 100755 --- a/examples/command/portals/databases/postgres/amazon_aurora/aws_cli/analysis_corp/run.sh +++ b/examples/command/portals/databases/postgres/amazon_aurora/aws_cli/analysis_corp/run.sh @@ -44,14 +44,14 @@ run() { aws ec2 create-key-pair --key-name "${name}-key" --query 'KeyMaterial' > key.pem chmod 400 key.pem - sed "s/\$ENROLLMENT_TICKET/${enrollment_ticket}/g" run_ockam.sh > user_data.sh + sed "s/\$ENROLLMENT_TICKET/${enrollment_ticket}/g" run_ockam.sh > user_data1.sh + sed "s/\$OCKAM_VERSION/${OCKAM_VERSION}/g" user_data1.sh > user_data.sh instance_id=$(aws ec2 run-instances --image-id "$ami_id" --instance-type c5n.large \ --subnet-id "$subnet_id" --security-group-ids "$sg_id" \ --key-name "${name}-key" --user-data file://user_data.sh --query 'Instances[0].InstanceId') aws ec2 create-tags --resources "$instance_id" --tags "Key=Name,Value=${name}-ec2-instance" aws ec2 wait instance-running --instance-ids "$instance_id" ip=$(aws ec2 describe-instances --instance-ids "$instance_id" --query 'Reservations[0].Instances[0].PublicIpAddress') - rm -f user_data.sh until scp -o StrictHostKeyChecking=no -i ./key.pem ./app.js "ec2-user@$ip:app.js"; do sleep 10; done ssh -o StrictHostKeyChecking=no -i ./key.pem "ec2-user@$ip" \ @@ -66,7 +66,7 @@ cleanup() { # ---------------------------------------------------------------------------------------------------------------- # DELETE INSTANCE - rm -f user_data.sh + rm -f user_data*.sh instance_ids=$(aws ec2 describe-instances --filters "Name=tag:Name,Values=${name}-ec2-instance" \ --query "Reservations[*].Instances[*].InstanceId") for i in $instance_ids; do diff --git a/examples/command/portals/databases/postgres/amazon_aurora/aws_cli/analysis_corp/run_ockam.sh b/examples/command/portals/databases/postgres/amazon_aurora/aws_cli/analysis_corp/run_ockam.sh index 68f58178148..e622ecd4c86 100755 --- a/examples/command/portals/databases/postgres/amazon_aurora/aws_cli/analysis_corp/run_ockam.sh +++ b/examples/command/portals/databases/postgres/amazon_aurora/aws_cli/analysis_corp/run_ockam.sh @@ -7,8 +7,10 @@ sudo -u ec2-user bash << 'EOS' set -ex # Install Ockam Command +export OCKAM_VERSION="$OCKAM_VERSION" curl --proto '=https' --tlsv1.2 -sSfL https://install.command.ockam.io | bash source "$HOME/.ockam/env" +ockam --version # Run `ockam project enroll ...` # diff --git a/examples/command/portals/databases/postgres/amazon_aurora/aws_cli/bank_corp/run.sh b/examples/command/portals/databases/postgres/amazon_aurora/aws_cli/bank_corp/run.sh index 5287589f610..97d91c1ff60 100755 --- a/examples/command/portals/databases/postgres/amazon_aurora/aws_cli/bank_corp/run.sh +++ b/examples/command/portals/databases/postgres/amazon_aurora/aws_cli/bank_corp/run.sh @@ -64,20 +64,20 @@ run() { "Name=virtualization-type,Values=hvm" "Name=root-device-type,Values=ebs" ) sed "s/\$ENROLLMENT_TICKET/${enrollment_ticket}/g" run_ockam.sh > user_data1.sh - sed "s/\$POSTGRES_ADDRESS/${db_endpoint}/g" user_data1.sh > user_data.sh + sed "s/\$OCKAM_VERSION/${OCKAM_VERSION}/g" user_data1.sh > user_data2.sh + sed "s/\$POSTGRES_ADDRESS/${db_endpoint}/g" user_data2.sh > user_data.sh instance_id=$(aws ec2 run-instances --image-id "$ami_id" --instance-type c5n.large \ --subnet-id "$subnet1_id" --security-group-ids "$sg_id" \ --user-data file://user_data.sh --query 'Instances[0].InstanceId') aws ec2 create-tags --resources "$instance_id" --tags "Key=Name,Value=${name}-ec2-instance" aws ec2 wait instance-running --instance-ids "$instance_id" - rm -f user_data.sh user_data1.sh } cleanup() { # ---------------------------------------------------------------------------------------------------------------- # DELETE INSTANCE - rm -f user_data.sh user_data1.sh + rm -rf user_data*.sh instance_ids=$(aws ec2 describe-instances --filters "Name=tag:Name,Values=${name}-ec2-instance" \ --query "Reservations[*].Instances[*].InstanceId") for i in $instance_ids; do diff --git a/examples/command/portals/databases/postgres/amazon_aurora/aws_cli/bank_corp/run_ockam.sh b/examples/command/portals/databases/postgres/amazon_aurora/aws_cli/bank_corp/run_ockam.sh index 50c63a121d8..9b77f08d32c 100644 --- a/examples/command/portals/databases/postgres/amazon_aurora/aws_cli/bank_corp/run_ockam.sh +++ b/examples/command/portals/databases/postgres/amazon_aurora/aws_cli/bank_corp/run_ockam.sh @@ -7,9 +7,12 @@ sudo -u ec2-user bash << 'EOS' set -ex # Install Ockam Command +export OCKAM_VERSION="$OCKAM_VERSION" curl --proto '=https' --tlsv1.2 -sSfL https://install.command.ockam.io | bash source "$HOME/.ockam/env" +ockam --version + # Run `ockam project enroll ...` # # The `project enroll` command creates a new vault and generates a cryptographic identity with diff --git a/examples/command/portals/databases/postgres/amazon_aurora/aws_cli/run.sh b/examples/command/portals/databases/postgres/amazon_aurora/aws_cli/run.sh index 7117c06a5b3..c7f9f20576f 100755 --- a/examples/command/portals/databases/postgres/amazon_aurora/aws_cli/run.sh +++ b/examples/command/portals/databases/postgres/amazon_aurora/aws_cli/run.sh @@ -44,6 +44,10 @@ run() { analysis_corp_ticket=$(ockam project ticket --usage-count 1 --expires-in 60m \ --attribute "postgres-inlet=true") + if [[ -n "$OCKAM_VERSION" ]]; then + export OCKAM_VERSION="v${OCKAM_VERSION}"; + fi + # Invoke `bank_corp/run.sh` in the directory that has bank_corp's configuration. Pass the above enrollment ticket # as the first argument to run.sh script. Read bank_corp/run.sh to understand the parts that are provisioned in # bank_corp's virtual private cloud. diff --git a/examples/command/portals/databases/postgres/amazon_rds/aws_cli/analysis_corp/app.js b/examples/command/portals/databases/postgres/amazon_rds/aws_cli/analysis_corp/app.js index 83a11e99853..a7cc1773714 100644 --- a/examples/command/portals/databases/postgres/amazon_rds/aws_cli/analysis_corp/app.js +++ b/examples/command/portals/databases/postgres/amazon_rds/aws_cli/analysis_corp/app.js @@ -62,8 +62,8 @@ async function run() { console.log( "\nThe example run was successful 🥳.\n" + - "\nThe app connected with the database through an encrypted portal." + - "\nCreated a table, inserted some data, and querried it back.\n", + "\nThe app connected with the database through an encrypted portal." + + "\nCreated a table, inserted some data, and querried it back.\n", ); } catch (err) { console.error("Error:", err.message); diff --git a/examples/command/portals/databases/postgres/amazon_rds/aws_cli/analysis_corp/run.sh b/examples/command/portals/databases/postgres/amazon_rds/aws_cli/analysis_corp/run.sh index eede904132b..8fa6aa94a51 100755 --- a/examples/command/portals/databases/postgres/amazon_rds/aws_cli/analysis_corp/run.sh +++ b/examples/command/portals/databases/postgres/amazon_rds/aws_cli/analysis_corp/run.sh @@ -44,14 +44,14 @@ run() { aws ec2 create-key-pair --key-name "${name}-key" --query 'KeyMaterial' > key.pem chmod 400 key.pem - sed "s/\$ENROLLMENT_TICKET/${enrollment_ticket}/g" run_ockam.sh > user_data.sh + sed "s/\$ENROLLMENT_TICKET/${enrollment_ticket}/g" run_ockam.sh > user_data1.sh + sed "s/\$OCKAM_VERSION/${OCKAM_VERSION}/g" user_data1.sh > user_data.sh instance_id=$(aws ec2 run-instances --image-id "$ami_id" --instance-type c5n.large \ --subnet-id "$subnet_id" --security-group-ids "$sg_id" \ --key-name "${name}-key" --user-data file://user_data.sh --query 'Instances[0].InstanceId') aws ec2 create-tags --resources "$instance_id" --tags "Key=Name,Value=${name}-ec2-instance" aws ec2 wait instance-running --instance-ids "$instance_id" ip=$(aws ec2 describe-instances --instance-ids "$instance_id" --query 'Reservations[0].Instances[0].PublicIpAddress') - rm -f user_data.sh until scp -o StrictHostKeyChecking=no -i ./key.pem ./app.js "ec2-user@$ip:app.js"; do sleep 10; done ssh -o StrictHostKeyChecking=no -i ./key.pem "ec2-user@$ip" \ @@ -66,7 +66,7 @@ cleanup() { # ---------------------------------------------------------------------------------------------------------------- # DELETE INSTANCE - rm -f user_data.sh + rm -rf user_data*.sh instance_ids=$(aws ec2 describe-instances --filters "Name=tag:Name,Values=${name}-ec2-instance" \ --query "Reservations[*].Instances[*].InstanceId") for i in $instance_ids; do diff --git a/examples/command/portals/databases/postgres/amazon_rds/aws_cli/analysis_corp/run_ockam.sh b/examples/command/portals/databases/postgres/amazon_rds/aws_cli/analysis_corp/run_ockam.sh index 68f58178148..ab422131eef 100755 --- a/examples/command/portals/databases/postgres/amazon_rds/aws_cli/analysis_corp/run_ockam.sh +++ b/examples/command/portals/databases/postgres/amazon_rds/aws_cli/analysis_corp/run_ockam.sh @@ -7,6 +7,7 @@ sudo -u ec2-user bash << 'EOS' set -ex # Install Ockam Command +export OCKAM_VERSION="$OCKAM_VERSION" curl --proto '=https' --tlsv1.2 -sSfL https://install.command.ockam.io | bash source "$HOME/.ockam/env" diff --git a/examples/command/portals/databases/postgres/amazon_rds/aws_cli/bank_corp/run.sh b/examples/command/portals/databases/postgres/amazon_rds/aws_cli/bank_corp/run.sh index ec3bedbc6ea..e01a4427e14 100755 --- a/examples/command/portals/databases/postgres/amazon_rds/aws_cli/bank_corp/run.sh +++ b/examples/command/portals/databases/postgres/amazon_rds/aws_cli/bank_corp/run.sh @@ -61,20 +61,20 @@ run() { "Name=virtualization-type,Values=hvm" "Name=root-device-type,Values=ebs" ) sed "s/\$ENROLLMENT_TICKET/${enrollment_ticket}/g" run_ockam.sh > user_data1.sh - sed "s/\$POSTGRES_ADDRESS/${db_endpoint}/g" user_data1.sh > user_data.sh + sed "s/\$OCKAM_VERSION/${OCKAM_VERSION}/g" user_data1.sh > user_data2.sh + sed "s/\$POSTGRES_ADDRESS/${db_endpoint}/g" user_data2.sh > user_data.sh instance_id=$(aws ec2 run-instances --image-id "$ami_id" --instance-type c5n.large \ --subnet-id "$subnet1_id" --security-group-ids "$sg_id" \ --user-data file://user_data.sh --query 'Instances[0].InstanceId') aws ec2 create-tags --resources "$instance_id" --tags "Key=Name,Value=${name}-ec2-instance" aws ec2 wait instance-running --instance-ids "$instance_id" - rm -f user_data.sh user_data1.sh } cleanup() { # ---------------------------------------------------------------------------------------------------------------- # DELETE INSTANCE - rm -f user_data.sh user_data1.sh + rm -rf user_data*.sh instance_ids=$(aws ec2 describe-instances --filters "Name=tag:Name,Values=${name}-ec2-instance" \ --query "Reservations[*].Instances[*].InstanceId") for i in $instance_ids; do diff --git a/examples/command/portals/databases/postgres/amazon_rds/aws_cli/bank_corp/run_ockam.sh b/examples/command/portals/databases/postgres/amazon_rds/aws_cli/bank_corp/run_ockam.sh index 50c63a121d8..9b77f08d32c 100644 --- a/examples/command/portals/databases/postgres/amazon_rds/aws_cli/bank_corp/run_ockam.sh +++ b/examples/command/portals/databases/postgres/amazon_rds/aws_cli/bank_corp/run_ockam.sh @@ -7,9 +7,12 @@ sudo -u ec2-user bash << 'EOS' set -ex # Install Ockam Command +export OCKAM_VERSION="$OCKAM_VERSION" curl --proto '=https' --tlsv1.2 -sSfL https://install.command.ockam.io | bash source "$HOME/.ockam/env" +ockam --version + # Run `ockam project enroll ...` # # The `project enroll` command creates a new vault and generates a cryptographic identity with diff --git a/examples/command/portals/databases/postgres/amazon_rds/aws_cli/run.sh b/examples/command/portals/databases/postgres/amazon_rds/aws_cli/run.sh index fb9bf46beb2..2288a519374 100755 --- a/examples/command/portals/databases/postgres/amazon_rds/aws_cli/run.sh +++ b/examples/command/portals/databases/postgres/amazon_rds/aws_cli/run.sh @@ -44,6 +44,10 @@ run() { analysis_corp_ticket=$(ockam project ticket --usage-count 1 --expires-in 60m \ --attribute "postgres-inlet=true") + if [[ -n "$OCKAM_VERSION" ]]; then + export OCKAM_VERSION="v${OCKAM_VERSION}"; + fi + # Invoke `bank_corp/run.sh` in the directory that has bank_corp's configuration. Pass the above enrollment ticket # as the first argument to run.sh script. Read bank_corp/run.sh to understand the parts that are provisioned in # bank_corp's virtual private cloud. diff --git a/examples/command/portals/databases/postgres/docker/analysis_corp/app.js b/examples/command/portals/databases/postgres/docker/analysis_corp/app.js index 620ec589ba8..82cfe0767e7 100644 --- a/examples/command/portals/databases/postgres/docker/analysis_corp/app.js +++ b/examples/command/portals/databases/postgres/docker/analysis_corp/app.js @@ -53,8 +53,8 @@ async function run() { console.log( "\nThe example run was successful 🥳.\n" + - "\nThe app connected with the database through an encrypted portal." + - "\nCreated a table, inserted some data, and querried it back.\n", + "\nThe app connected with the database through an encrypted portal." + + "\nCreated a table, inserted some data, and querried it back.\n", ); } catch (err) { console.error("Error:", err.message); diff --git a/examples/command/portals/databases/postgres/docker/analysis_corp/docker-compose.yml b/examples/command/portals/databases/postgres/docker/analysis_corp/docker-compose.yml index 63c1187a8ac..4c69634063f 100644 --- a/examples/command/portals/databases/postgres/docker/analysis_corp/docker-compose.yml +++ b/examples/command/portals/databases/postgres/docker/analysis_corp/docker-compose.yml @@ -14,6 +14,8 @@ services: build: context: . dockerfile: ../ockam.dockerfile + args: + OCKAM_VERSION: ${OCKAM_VERSION:-latest} environment: ENROLLMENT_TICKET: ${ENROLLMENT_TICKET:-} OCKAM_DEVELOPER: ${OCKAM_DEVELOPER:-false} @@ -26,6 +28,7 @@ services: # the app is doing. app: depends_on: [ockam] + container_name: analysis_corp-app build: context: . dockerfile: app.dockerfile diff --git a/examples/command/portals/databases/postgres/docker/bank_corp/docker-compose.yml b/examples/command/portals/databases/postgres/docker/bank_corp/docker-compose.yml index eaceaa51977..046d8f3529b 100644 --- a/examples/command/portals/databases/postgres/docker/bank_corp/docker-compose.yml +++ b/examples/command/portals/databases/postgres/docker/bank_corp/docker-compose.yml @@ -25,6 +25,8 @@ services: build: context: . dockerfile: ../ockam.dockerfile + args: + OCKAM_VERSION: ${OCKAM_VERSION:-latest} environment: ENROLLMENT_TICKET: ${ENROLLMENT_TICKET:-} OCKAM_DEVELOPER: ${OCKAM_DEVELOPER:-false} diff --git a/examples/command/portals/databases/postgres/docker/ockam.dockerfile b/examples/command/portals/databases/postgres/docker/ockam.dockerfile index 36ed28007d9..546ea06c6a4 100644 --- a/examples/command/portals/databases/postgres/docker/ockam.dockerfile +++ b/examples/command/portals/databases/postgres/docker/ockam.dockerfile @@ -9,7 +9,9 @@ # Read bank_corp/run_ockam.sh and analysis_corp/run_ockam.sh to understand # how each node is set up. -FROM ghcr.io/build-trust/ockam as builder +ARG OCKAM_VERSION=latest + +FROM ghcr.io/build-trust/ockam:${OCKAM_VERSION} as builder FROM cgr.dev/chainguard/bash COPY --from=builder /ockam /usr/local/bin/ockam diff --git a/examples/command/portals/databases/postgres/kubernetes/analysis_corp/app.js b/examples/command/portals/databases/postgres/kubernetes/analysis_corp/app.js index ff07d1c3b70..f921283a76c 100644 --- a/examples/command/portals/databases/postgres/kubernetes/analysis_corp/app.js +++ b/examples/command/portals/databases/postgres/kubernetes/analysis_corp/app.js @@ -53,8 +53,8 @@ async function run() { console.log( "\nThe example run was successful 🥳.\n" + - "\nThe app connected with the database through an encrypted portal." + - "\nCreated a table, inserted some data, and querried it back.\n", + "\nThe app connected with the database through an encrypted portal." + + "\nCreated a table, inserted some data, and querried it back.\n", ); } catch (err) { console.error("Error:", err.message); diff --git a/examples/command/portals/databases/postgres/kubernetes/ockam.dockerfile b/examples/command/portals/databases/postgres/kubernetes/ockam.dockerfile index 36ed28007d9..546ea06c6a4 100644 --- a/examples/command/portals/databases/postgres/kubernetes/ockam.dockerfile +++ b/examples/command/portals/databases/postgres/kubernetes/ockam.dockerfile @@ -9,7 +9,9 @@ # Read bank_corp/run_ockam.sh and analysis_corp/run_ockam.sh to understand # how each node is set up. -FROM ghcr.io/build-trust/ockam as builder +ARG OCKAM_VERSION=latest + +FROM ghcr.io/build-trust/ockam:${OCKAM_VERSION} as builder FROM cgr.dev/chainguard/bash COPY --from=builder /ockam /usr/local/bin/ockam diff --git a/examples/command/portals/databases/postgres/kubernetes/run.sh b/examples/command/portals/databases/postgres/kubernetes/run.sh index 3d205a37b08..3ce24d2dd39 100755 --- a/examples/command/portals/databases/postgres/kubernetes/run.sh +++ b/examples/command/portals/databases/postgres/kubernetes/run.sh @@ -97,11 +97,15 @@ run() { build_and_load_docker_image() { tag="$1"; dockerfile="$2"; context="$3"; cluster="$4" + if [[ -z $OCKAM_VERSION ]]; then + export OCKAM_VERSION="latest" + fi + # Use --load option only if docker buildx is available. if docker buildx ls &>/dev/null; then - docker build --load --file "$dockerfile" --tag "$tag" "$context" + docker build --build-arg OCKAM_VERSION="$OCKAM_VERSION" --load --file "$dockerfile" --tag "$tag" "$context" else - docker build --file "$dockerfile" --tag "$tag" "$context" + docker build --build-arg OCKAM_VERSION="$OCKAM_VERSION" --file "$dockerfile" --tag "$tag" "$context" fi kind load docker-image "$tag" --name "$cluster" diff --git a/examples/command/portals/kafka/aiven/application_team/docker-compose.yml b/examples/command/portals/kafka/aiven/application_team/docker-compose.yml index d2fc2954736..7e6bbedaf03 100644 --- a/examples/command/portals/kafka/aiven/application_team/docker-compose.yml +++ b/examples/command/portals/kafka/aiven/application_team/docker-compose.yml @@ -12,6 +12,8 @@ services: build: context: . dockerfile: ../kafka_ockam.dockerfile + args: + OCKAM_VERSION: ${OCKAM_VERSION:-latest} environment: ENROLLMENT_TICKET: ${CONSUMER_ENROLLMENT_TICKET:-} KAFKA_CLUSTER_API_KEY: ${KAFKA_CLUSTER_API_KEY:-} @@ -30,10 +32,13 @@ services: echo "Press Ctrl+C to stop the container at any time, then execute "\ "'./run.sh cleanup' to remove all containers."; echo ""; - kafka-console-consumer.sh --topic demo --bootstrap-server 127.0.0.1:9092 --consumer.config kafka.config --max-messages 8; - if [ "$?" == "0" ]; then - echo "The example run was successful 🥳"; + kafka-console-consumer.sh --topic demo --timeout-ms 50000 --bootstrap-server 127.0.0.1:9092 --consumer.config kafka.config --max-messages 8 | tee output.txt; + if [[ ! -s output.txt ]]; then + echo "Failed to receive messages"; + exit 1; fi; + + echo "The example run was successful 🥳."; echo "Messages received successfully, please Ctrl+C to exit"; tail -f /dev/null; ) diff --git a/examples/command/portals/kafka/aiven/kafka_ockam.dockerfile b/examples/command/portals/kafka/aiven/kafka_ockam.dockerfile index 92fa4fa4a4b..67eb781b6dc 100644 --- a/examples/command/portals/kafka/aiven/kafka_ockam.dockerfile +++ b/examples/command/portals/kafka/aiven/kafka_ockam.dockerfile @@ -1,4 +1,6 @@ -FROM ghcr.io/build-trust/ockam as builder +ARG OCKAM_VERSION=latest + +FROM ghcr.io/build-trust/ockam:${OCKAM_VERSION} as builder FROM alpine:3 COPY --from=builder /ockam /usr/local/bin/ockam diff --git a/examples/command/portals/kafka/apache/docker/application_team/docker-compose.yml b/examples/command/portals/kafka/apache/docker/application_team/docker-compose.yml index 198cb90d710..a411ea90435 100644 --- a/examples/command/portals/kafka/apache/docker/application_team/docker-compose.yml +++ b/examples/command/portals/kafka/apache/docker/application_team/docker-compose.yml @@ -8,9 +8,12 @@ services: # Read kafka_ockam.dockerfile and run_ockam.sh to understand # how the node is set up. consumer: + container_name: application_team-consumer build: context: . dockerfile: ../kafka_ockam.dockerfile + args: + OCKAM_VERSION: ${OCKAM_VERSION:-latest} environment: ENROLLMENT_TICKET: ${CONSUMER_ENROLLMENT_TICKET:-} OCKAM_DEVELOPER: ${OCKAM_DEVELOPER:-false} @@ -25,10 +28,12 @@ services: echo "Press Ctrl+C to stop the container at any time, then execute "\ "'./run.sh cleanup' to remove all containers."; echo ""; - kafka-console-consumer.sh --topic demo --bootstrap-server 127.0.0.1:9092 --max-messages 8; - if [ "$?" == "0" ]; then - echo "The example run was successful 🥳"; + kafka-console-consumer.sh --topic demo --timeout-ms 50000 --bootstrap-server 127.0.0.1:9092 --max-messages 8 | tee output.txt; + if [[ ! -s output.txt ]]; then + echo "Failed to receive messages"; + exit 1; fi; + echo "The example run was successful 🥳."; echo "Messages received successfully, please Ctrl+C to exit"; tail -f /dev/null; ) @@ -36,6 +41,7 @@ services: - application_team producer: + container_name: application_team-producer build: context: . dockerfile: ../kafka_ockam.dockerfile @@ -47,6 +53,7 @@ services: command: - -c - ( + set -e; MESSAGES=( "Message - 🔥" "Message - 🌟" diff --git a/examples/command/portals/kafka/apache/docker/kafka_ockam.dockerfile b/examples/command/portals/kafka/apache/docker/kafka_ockam.dockerfile index 92fa4fa4a4b..67eb781b6dc 100644 --- a/examples/command/portals/kafka/apache/docker/kafka_ockam.dockerfile +++ b/examples/command/portals/kafka/apache/docker/kafka_ockam.dockerfile @@ -1,4 +1,6 @@ -FROM ghcr.io/build-trust/ockam as builder +ARG OCKAM_VERSION=latest + +FROM ghcr.io/build-trust/ockam:${OCKAM_VERSION} as builder FROM alpine:3 COPY --from=builder /ockam /usr/local/bin/ockam diff --git a/examples/command/portals/kafka/apache/docker/kafka_operator/docker-compose.yml b/examples/command/portals/kafka/apache/docker/kafka_operator/docker-compose.yml index 5acdce8850f..c2a7daf3b8b 100644 --- a/examples/command/portals/kafka/apache/docker/kafka_operator/docker-compose.yml +++ b/examples/command/portals/kafka/apache/docker/kafka_operator/docker-compose.yml @@ -29,6 +29,8 @@ services: build: context: . dockerfile: ../kafka_ockam.dockerfile + args: + OCKAM_VERSION: ${OCKAM_VERSION:-latest} environment: ENROLLMENT_TICKET: ${ENROLLMENT_TICKET:-} OCKAM_DEVELOPER: ${OCKAM_DEVELOPER:-false} diff --git a/examples/command/portals/kafka/confluent/application_team/docker-compose.yml b/examples/command/portals/kafka/confluent/application_team/docker-compose.yml index 44ddc0dcd7e..89fa94f0d72 100644 --- a/examples/command/portals/kafka/confluent/application_team/docker-compose.yml +++ b/examples/command/portals/kafka/confluent/application_team/docker-compose.yml @@ -12,6 +12,8 @@ services: build: context: . dockerfile: ../kafka_ockam.dockerfile + args: + OCKAM_VERSION: ${OCKAM_VERSION:-latest} environment: ENROLLMENT_TICKET: ${CONSUMER_ENROLLMENT_TICKET:-} CONFLUENT_CLOUD_KAFKA_CLUSTER_API_KEY: ${CONFLUENT_CLOUD_KAFKA_CLUSTER_API_KEY:-} @@ -29,10 +31,13 @@ services: echo "Press Ctrl+C to stop the container at any time, then execute "\ "'./run.sh cleanup' to remove all containers."; echo ""; - kafka-console-consumer.sh --topic demo --bootstrap-server 127.0.0.1:9092 --consumer.config kafka.config --max-messages 8; - if [ "$?" == "0" ]; then - echo "The example run was successful 🥳"; + kafka-console-consumer.sh --topic demo --timeout-ms 50000 --bootstrap-server 127.0.0.1:9092 --consumer.config kafka.config --max-messages 8 | tee output.txt; + if [[ ! -s output.txt ]]; then + echo "Failed to receive messages"; + exit 1; fi; + + echo "The example run was successful 🥳."; echo "Messages received successfully, please Ctrl+C to exit"; tail -f /dev/null; ) diff --git a/examples/command/portals/kafka/confluent/kafka_ockam.dockerfile b/examples/command/portals/kafka/confluent/kafka_ockam.dockerfile index 92fa4fa4a4b..67eb781b6dc 100644 --- a/examples/command/portals/kafka/confluent/kafka_ockam.dockerfile +++ b/examples/command/portals/kafka/confluent/kafka_ockam.dockerfile @@ -1,4 +1,6 @@ -FROM ghcr.io/build-trust/ockam as builder +ARG OCKAM_VERSION=latest + +FROM ghcr.io/build-trust/ockam:${OCKAM_VERSION} as builder FROM alpine:3 COPY --from=builder /ockam /usr/local/bin/ockam diff --git a/examples/command/portals/kafka/instaclustr/docker/application_team/docker-compose.yml b/examples/command/portals/kafka/instaclustr/docker/application_team/docker-compose.yml index 18d890ce601..cb6ce8f7c83 100644 --- a/examples/command/portals/kafka/instaclustr/docker/application_team/docker-compose.yml +++ b/examples/command/portals/kafka/instaclustr/docker/application_team/docker-compose.yml @@ -12,6 +12,8 @@ services: build: context: . dockerfile: kafka_client.dockerfile + args: + OCKAM_VERSION: ${OCKAM_VERSION:-latest} environment: ENROLLMENT_TICKET: ${CONSUMER_ENROLLMENT_TICKET:-} OCKAM_DEVELOPER: ${OCKAM_DEVELOPER:-false} @@ -28,12 +30,14 @@ services: echo "======================================================================="; echo "Press Ctrl+C to stop the container at any time, then execute './run.sh cleanup' to remove all containers."; echo ""; - kafka-console-consumer.sh --topic demo --bootstrap-server 127.0.0.1:9092 --consumer.config kafka.config --max-messages 8; - if [ "$?" -eq 0 ]; then - echo "Messages received successfully"; - echo "The example run was successful 🥳"; - echo "The consumer was able to decrypt messages, Instaclustr only saw encrypted messages"; + kafka-console-consumer.sh --topic demo --timeout-ms 50000 --bootstrap-server 127.0.0.1:9092 --consumer.config kafka.config --max-messages 8 | tee output.txt; + if [[ ! -s output.txt ]]; then + echo "Failed to receive messages"; + exit 1; fi; + echo "Messages received successfully"; + echo "The example run was successful 🥳."; + echo "The consumer was able to decrypt messages, Instaclustr only saw encrypted messages"; echo "Messages received successfully, please Ctrl+C to exit"; tail -f /dev/null; ) diff --git a/examples/command/portals/kafka/instaclustr/docker/application_team/kafka_client.dockerfile b/examples/command/portals/kafka/instaclustr/docker/application_team/kafka_client.dockerfile index 8040af8ff8a..eac70641113 100644 --- a/examples/command/portals/kafka/instaclustr/docker/application_team/kafka_client.dockerfile +++ b/examples/command/portals/kafka/instaclustr/docker/application_team/kafka_client.dockerfile @@ -1,3 +1,6 @@ +ARG OCKAM_VERSION=latest + +FROM ghcr.io/build-trust/ockam:${OCKAM_VERSION} as builder FROM alpine:3 # Install Kafka client @@ -19,8 +22,7 @@ RUN mirror=$(curl --stderr /dev/null https://www.apache.org/dyn/closer.cgi\?as_j ENV PATH "/sbin:/opt/kafka/bin/:$PATH" # Install Ockam -RUN curl --proto '=https' --tlsv1.2 -sSfL https://install.command.ockam.io | bash -s -ENV PATH "/root/.ockam/bin:$PATH" +COPY --from=builder /ockam /usr/local/bin/ockam # Copy the script that will be used as entrypoint COPY run_ockam.sh /run_ockam.sh diff --git a/examples/command/portals/kafka/instaclustr/docker/instaclustr_operator/docker-compose.yml b/examples/command/portals/kafka/instaclustr/docker/instaclustr_operator/docker-compose.yml index 59592461aea..2db8bec098b 100644 --- a/examples/command/portals/kafka/instaclustr/docker/instaclustr_operator/docker-compose.yml +++ b/examples/command/portals/kafka/instaclustr/docker/instaclustr_operator/docker-compose.yml @@ -12,6 +12,8 @@ services: build: context: . dockerfile: ../ockam.dockerfile + args: + OCKAM_VERSION: ${OCKAM_VERSION:-latest} environment: ENROLLMENT_TICKET: ${ENROLLMENT_TICKET:-} INSTACLUSTER_ADDRESS: ${BOOTSTRAPSERVER}:9092 diff --git a/examples/command/portals/kafka/instaclustr/docker/ockam.dockerfile b/examples/command/portals/kafka/instaclustr/docker/ockam.dockerfile index 0dfbaa456ee..07216caa8df 100644 --- a/examples/command/portals/kafka/instaclustr/docker/ockam.dockerfile +++ b/examples/command/portals/kafka/instaclustr/docker/ockam.dockerfile @@ -8,7 +8,9 @@ # # Read instaclustr_operator/run_ockam.sh how the node is set up. -FROM ghcr.io/build-trust/ockam as builder +ARG OCKAM_VERSION=latest + +FROM ghcr.io/build-trust/ockam:${OCKAM_VERSION} as builder FROM cgr.dev/chainguard/wolfi-base RUN apk add --update --no-cache bind-tools bash diff --git a/examples/command/portals/kafka/redpanda/docker/application_team/docker-compose.yml b/examples/command/portals/kafka/redpanda/docker/application_team/docker-compose.yml index 3367a33e19d..a14c4592b82 100644 --- a/examples/command/portals/kafka/redpanda/docker/application_team/docker-compose.yml +++ b/examples/command/portals/kafka/redpanda/docker/application_team/docker-compose.yml @@ -9,9 +9,12 @@ services: # Read kafka_client.dockerfile and run_ockam.sh to understand # how the node is set up. consumer: + container_name: application_team-consumer build: context: . dockerfile: kafka_client.dockerfile + args: + OCKAM_VERSION: ${OCKAM_VERSION:-latest} environment: ENROLLMENT_TICKET: ${CONSUMER_ENROLLMENT_TICKET:-} OCKAM_DEVELOPER: ${OCKAM_DEVELOPER:-false} @@ -28,19 +31,24 @@ services: echo "Press Ctrl+C to stop the container at any time, then execute "\ "'./run.sh cleanup' to remove all containers."; echo ""; - kafka-console-consumer.sh --topic demo --bootstrap-server 127.0.0.1:9092 --max-messages 8; - if [ "$?" == "0" ]; then - echo ""; - echo "The example run was successful 🥳"; - echo "The consumer was able to decrypt messages, Redpanda only saw encrypted messages"; - echo ""; + kafka-console-consumer.sh --topic demo --timeout-ms 50000 --bootstrap-server 127.0.0.1:9092 --max-messages 8 | tee output.txt; + if [[ ! -s output.txt ]]; then + echo "Failed to receive messages"; + exit 1; fi; + + echo ""; + echo "The example run was successful 🥳."; + echo "The consumer was able to decrypt messages, Redpanda only saw encrypted messages"; + echo ""; + echo "======================================================================="; echo "Open the console at http://127.0.0.1:8080 to see the encryted messages."; echo "======================================================================="; tail -f /dev/null; ) producer: + container_name: application_team-producer build: context: . dockerfile: kafka_client.dockerfile diff --git a/examples/command/portals/kafka/redpanda/docker/application_team/kafka_client.dockerfile b/examples/command/portals/kafka/redpanda/docker/application_team/kafka_client.dockerfile index 8040af8ff8a..eac70641113 100644 --- a/examples/command/portals/kafka/redpanda/docker/application_team/kafka_client.dockerfile +++ b/examples/command/portals/kafka/redpanda/docker/application_team/kafka_client.dockerfile @@ -1,3 +1,6 @@ +ARG OCKAM_VERSION=latest + +FROM ghcr.io/build-trust/ockam:${OCKAM_VERSION} as builder FROM alpine:3 # Install Kafka client @@ -19,8 +22,7 @@ RUN mirror=$(curl --stderr /dev/null https://www.apache.org/dyn/closer.cgi\?as_j ENV PATH "/sbin:/opt/kafka/bin/:$PATH" # Install Ockam -RUN curl --proto '=https' --tlsv1.2 -sSfL https://install.command.ockam.io | bash -s -ENV PATH "/root/.ockam/bin:$PATH" +COPY --from=builder /ockam /usr/local/bin/ockam # Copy the script that will be used as entrypoint COPY run_ockam.sh /run_ockam.sh diff --git a/examples/command/portals/kafka/redpanda/docker/ockam.dockerfile b/examples/command/portals/kafka/redpanda/docker/ockam.dockerfile index 6e710d8d362..051b979d4aa 100644 --- a/examples/command/portals/kafka/redpanda/docker/ockam.dockerfile +++ b/examples/command/portals/kafka/redpanda/docker/ockam.dockerfile @@ -8,7 +8,9 @@ # # Read redpanda_operator/run_ockam.sh how the node is set up. -FROM ghcr.io/build-trust/ockam as builder +ARG OCKAM_VERSION=latest + +FROM ghcr.io/build-trust/ockam:${OCKAM_VERSION} as builder FROM cgr.dev/chainguard/wolfi-base RUN apk add --update --no-cache bind-tools bash diff --git a/examples/command/portals/kafka/redpanda/docker/redpanda_operator/docker-compose.yml b/examples/command/portals/kafka/redpanda/docker/redpanda_operator/docker-compose.yml index 570d25422dd..2983a829689 100644 --- a/examples/command/portals/kafka/redpanda/docker/redpanda_operator/docker-compose.yml +++ b/examples/command/portals/kafka/redpanda/docker/redpanda_operator/docker-compose.yml @@ -13,6 +13,8 @@ services: build: context: . dockerfile: ../ockam.dockerfile + args: + OCKAM_VERSION: ${OCKAM_VERSION:-latest} environment: ENROLLMENT_TICKET: ${ENROLLMENT_TICKET:-} OCKAM_DEVELOPER: ${OCKAM_DEVELOPER:-false} diff --git a/examples/command/portals/kafka/redpanda/docker/run.sh b/examples/command/portals/kafka/redpanda/docker/run.sh index 08f34bb71ac..1570a51d47d 100755 --- a/examples/command/portals/kafka/redpanda/docker/run.sh +++ b/examples/command/portals/kafka/redpanda/docker/run.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -set -e +set -ex # This script, `./run.sh ...` is invoked on a developer’s work machine. # diff --git a/examples/command/portals/kafka/warpstream/application_team/docker-compose.yml b/examples/command/portals/kafka/warpstream/application_team/docker-compose.yml index 1b6c9cc2a8c..8105aa1ff1d 100644 --- a/examples/command/portals/kafka/warpstream/application_team/docker-compose.yml +++ b/examples/command/portals/kafka/warpstream/application_team/docker-compose.yml @@ -10,9 +10,12 @@ services: # Read kafka_ockam.dockerfile and run_ockam.sh to understand # how the node is set up. consumer: + container_name: application_team-consumer build: context: . dockerfile: kafka_client.dockerfile + args: + OCKAM_VERSION: ${OCKAM_VERSION:-latest} environment: ENROLLMENT_TICKET: ${CONSUMER_ENROLLMENT_TICKET:-} KAFKA_CLUSTER_API_KEY: ${KAFKA_CLUSTER_API_KEY:-} @@ -31,15 +34,19 @@ services: echo "Press Ctrl+C to stop the container at any time, then execute "\ "'./run.sh cleanup' to remove all containers."; echo ""; - kafka-console-consumer.sh --topic demo --bootstrap-server 127.0.0.1:9092 --consumer.config kafka.config --max-messages 8; - if [ "$$?" == "0" ]; then - echo "The example run was successful 🥳"; + kafka-console-consumer.sh --topic demo --timeout-ms 50000 --bootstrap-server 127.0.0.1:9092 --consumer.config kafka.config --max-messages 8 | tee output.txt; + if [[ ! -s output.txt ]]; then + echo "Failed to receive messages"; + exit 1; fi; + + echo "The example run was successful 🥳."; echo "Messages received successfully, please Ctrl+C to exit"; tail -f /dev/null; ) producer: + container_name: application_team-producer build: context: . dockerfile: kafka_client.dockerfile diff --git a/examples/command/portals/kafka/warpstream/application_team/kafka_client.dockerfile b/examples/command/portals/kafka/warpstream/application_team/kafka_client.dockerfile index 8040af8ff8a..eac70641113 100644 --- a/examples/command/portals/kafka/warpstream/application_team/kafka_client.dockerfile +++ b/examples/command/portals/kafka/warpstream/application_team/kafka_client.dockerfile @@ -1,3 +1,6 @@ +ARG OCKAM_VERSION=latest + +FROM ghcr.io/build-trust/ockam:${OCKAM_VERSION} as builder FROM alpine:3 # Install Kafka client @@ -19,8 +22,7 @@ RUN mirror=$(curl --stderr /dev/null https://www.apache.org/dyn/closer.cgi\?as_j ENV PATH "/sbin:/opt/kafka/bin/:$PATH" # Install Ockam -RUN curl --proto '=https' --tlsv1.2 -sSfL https://install.command.ockam.io | bash -s -ENV PATH "/root/.ockam/bin:$PATH" +COPY --from=builder /ockam /usr/local/bin/ockam # Copy the script that will be used as entrypoint COPY run_ockam.sh /run_ockam.sh diff --git a/examples/command/portals/kafka/warpstream/run.sh b/examples/command/portals/kafka/warpstream/run.sh index 4ea855c3bc6..a07ac5a94e3 100755 --- a/examples/command/portals/kafka/warpstream/run.sh +++ b/examples/command/portals/kafka/warpstream/run.sh @@ -29,6 +29,7 @@ run() { ockam enroll # Create a Cluster in Warpstream + echo "$WARPSTREAM_API_KEY $OCKAM_VERSION" if [[ -z $WARPSTREAM_API_KEY ]]; then echo "ERROR: Please provide your Warpstream API key as an environment variable 'WARPSTREAM_API_KEY'" && exit 1; fi; cluster_detail=$(curl --silent --show-error --fail https://api.prod.us-east-1.warpstream.com/api/v1/create_virtual_cluster \ @@ -70,7 +71,7 @@ run() { # Cleanup after the example - `./run.sh cleanup` # Remove all containers and images pulled or created by docker compose. cleanup() { - if [[ -z $WARPSTREAM_API_KEY ]]; then echo "ERROR: Please provide your Warpstream API key as an environment variable 'WARPSTREAM_API_KEY'" && exit 1; fi; + if [[ -z $WARPSTREAM_API_KEY ]]; then echo "ERROR: Please provide your Warpstream API key" && exit 1; fi; pushd application_team; docker compose down --rmi all --remove-orphans; popd clusters=$(curl --silent --show-error --fail https://api.prod.us-east-1.warpstream.com/api/v1/list_virtual_clusters \ diff --git a/implementations/rust/ockam/ockam_command/tests/bats/examples/ai.bats b/implementations/rust/ockam/ockam_command/tests/bats/examples/ai.bats new file mode 100644 index 00000000000..27cbcaf4e59 --- /dev/null +++ b/implementations/rust/ockam/ockam_command/tests/bats/examples/ai.bats @@ -0,0 +1,33 @@ +#!/bin/bash + +# ===== SETUP + +setup() { + load ../load/base.bash + load ../load/orchestrator.bash + load ./setup.bash + load_bats_ext + setup_home_dir + skip_if_orchestrator_tests_not_enabled + copy_enrolled_home_dir +} + +teardown() { + ./run.sh cleanup || true + popd + teardown_home_dir +} + +# ===== TESTS + +@test "examples - ai - amazon_bedrock" { + pushd examples/command/portals/ai/amazon_bedrock + run_success ./run.sh + assert_output --partial "The example run was successful 🥳."$'\n' +} + +@test "examples - ai - amazon_ec2" { + pushd examples/command/portals/ai/amazon_ec2 + run_success ./run.sh + assert_output --partial "The example run was successful 🥳."$'\n' +} diff --git a/implementations/rust/ockam/ockam_command/tests/bats/examples/apis.bats b/implementations/rust/ockam/ockam_command/tests/bats/examples/apis.bats new file mode 100644 index 00000000000..f7276761176 --- /dev/null +++ b/implementations/rust/ockam/ockam_command/tests/bats/examples/apis.bats @@ -0,0 +1,32 @@ +#!/bin/bash + +# ===== SETUP + +setup() { + load ../load/base.bash + load ../load/orchestrator.bash + load ./setup.bash + load_bats_ext + setup_home_dir + skip_if_orchestrator_tests_not_enabled + copy_enrolled_home_dir +} + +teardown() { + ./run.sh cleanup || true + popd + teardown_home_dir +} + +# pass +@test "examples - apis - nodejs amazon_ec2" { + pushd examples/command/portals/apis/nodejs/amazon_ec2/aws_cli + run_success ./run.sh + assert_output --partial "The example run was successful 🥳."$'\n' +} + +@test "examples - apis - python amazon_ec2" { + pushd examples/command/portals/apis/python/amazon_ec2/aws_cli + run_success ./run.sh + assert_output --partial "The example run was successful 🥳."$'\n' +} diff --git a/implementations/rust/ockam/ockam_command/tests/bats/examples/coderepos.bats b/implementations/rust/ockam/ockam_command/tests/bats/examples/coderepos.bats new file mode 100644 index 00000000000..df98d43c911 --- /dev/null +++ b/implementations/rust/ockam/ockam_command/tests/bats/examples/coderepos.bats @@ -0,0 +1,25 @@ +#!/bin/bash + +# ===== SETUP + +setup() { + load ../load/base.bash + load ../load/orchestrator.bash + load ./setup.bash + load_bats_ext + setup_home_dir + skip_if_orchestrator_tests_not_enabled + copy_enrolled_home_dir +} + +teardown() { + ./run.sh cleanup || true + popd || true + teardown_home_dir +} + +@test "examples - coderepos amazon ec2" { + pushd examples/command/portals/coderepos/gitlab/amazon_ec2/aws_cli + run_success ./run.sh + assert_output --partial "The example run was successful 🥳."$'\n' +} diff --git a/implementations/rust/ockam/ockam_command/tests/bats/examples/databases.bats b/implementations/rust/ockam/ockam_command/tests/bats/examples/databases.bats new file mode 100644 index 00000000000..c4def6c93cf --- /dev/null +++ b/implementations/rust/ockam/ockam_command/tests/bats/examples/databases.bats @@ -0,0 +1,93 @@ +#!/bin/bash + +# ===== SETUP + +setup() { + load ../load/base.bash + load ../load/orchestrator.bash + load ./setup.bash + load_bats_ext + setup_home_dir + skip_if_orchestrator_tests_not_enabled + copy_enrolled_home_dir +} + +teardown() { + if [[ -z $BATS_TEST_COMPLETED ]]; then + echo "Test failed $(pwd)" >&3 + cat log.txt >&3 || true + fi + + ./run.sh cleanup || true + popd || true + teardown_home_dir +} + +# ===== TESTS + +# fail - bad +# @test "examples - database - influxdb amazon_timestream" { +# cd examples/command/portals/databases/influxdb/amazon_timestream/aws_cli +# run_success ./run.sh +# assert_output --partial "The example run was successful 🥳."$'\n' +# } + +@test "examples - database - mongodb amazon_vpc" { + pushd examples/command/portals/databases/mongodb/amazon_vpc + run_success ./run.sh + assert_output --partial "The example run was successful 🥳."$'\n' +} + +@test "examples - database - mongodb docker" { + pushd examples/command/portals/databases/mongodb/docker + ./run.sh >log.txt & + BGPID=$! + trap 'kill $BGPID; exit' INT + + container_to_watch="analysis_corp-app" + run_success wait_till_container_starts "$container_to_watch" + + exit_on_successful "$container_to_watch" & + + wait_till_successful_run_or_error "$container_to_watch" + assert_equal "$exit_code" "0" +} + +@test "examples - database - mongodb kubernetes" { + pushd examples/command/portals/databases/mongodb/kubernetes + run_success ./run.sh + assert_output --partial "The example run was successful 🥳."$'\n' +} + +@test "examples - database - postgres amazon_aurora" { + pushd examples/command/portals/databases/postgres/amazon_aurora/aws_cli + run_success ./run.sh + assert_output --partial "The example run was successful 🥳."$'\n' +} + +@test "examples - database - postgres amazon_rds" { + pushd examples/command/portals/databases/postgres/amazon_rds/aws_cli + run_success ./run.sh + assert_output --partial "The example run was successful 🥳."$'\n' +} + +@test "examples - database - postgres docker" { + pushd examples/command/portals/databases/postgres/docker + ./run.sh >log.txt & + BGPID=$! + trap 'kill $BGPID; exit' INT + + container_to_watch="analysis_corp-app" + run_success wait_till_container_starts "$container_to_watch" + + exit_on_successful "$container_to_watch" & + + wait_till_successful_run_or_error "$container_to_watch" + assert_equal "$exit_code" "0" +} + +@test "examples - database - postgres kubernetes" { + pushd examples/command/portals/databases/postgres/kubernetes + run_success ./run.sh + assert_output --partial "The example run was successful 🥳."$'\n' +} diff --git a/implementations/rust/ockam/ockam_command/tests/bats/examples/kafka.bats b/implementations/rust/ockam/ockam_command/tests/bats/examples/kafka.bats new file mode 100644 index 00000000000..5e599a45594 --- /dev/null +++ b/implementations/rust/ockam/ockam_command/tests/bats/examples/kafka.bats @@ -0,0 +1,124 @@ +#!/bin/bash + +# ===== SETUP + +setup() { + load ../load/base.bash + load ../load/orchestrator.bash + load ./setup.bash + load_bats_ext + setup_home_dir + skip_if_orchestrator_tests_not_enabled + copy_enrolled_home_dir +} + +teardown() { + if [[ -z $BATS_TEST_COMPLETED ]]; then + echo "Test failed $(pwd)" >&3 + cat log.txt >&3 || true + fi + + ./run.sh cleanup $EXTRA_ARG || true + unset EXTRA_ARG + cd - + teardown_home_dir +} + +# ===== TESTS + +@test "examples - kafka - aiven serverless" { + skip + container_to_watch="application_team-consumer" + cd examples/command/portals/kafka/aiven + ./run.sh >/dev/null & + BGPID=$! + trap 'kill $BGPID; exit' INT + + run_success wait_till_container_starts "$container_to_watch" + + exit_on_successful "$container_to_watch" & + + wait_till_successful_run_or_error "$container_to_watch" + assert_equal "$exit_code" "0" +} + +@test "examples - kafka - apache docker" { + container_to_watch="application_team-consumer" + + cd examples/command/portals/kafka/apache/docker + ./run.sh >log.txt & + BGPID=$! + trap 'kill $BGPID; exit' INT + + run_success wait_till_container_starts "$container_to_watch" + + exit_on_successful "$container_to_watch" & + + wait_till_successful_run_or_error "$container_to_watch" + assert_equal "$exit_code" "0" +} + +@test "examples - kafka - confluent serverless" { + skip + container_to_watch="application_team-consumer" + cd examples/command/portals/kafka/confluent + ./run.sh >/dev/null & + BGPID=$! + trap 'kill $BGPID; exit' INT + + run_success wait_till_container_starts "$container_to_watch" + + exit_on_successful "$container_to_watch" & + + wait_till_successful_run_or_error "$container_to_watch" + assert_equal "$exit_code" "0" +} + +@test "examples - kafka - instaclustr serverless" { + skip + container_to_watch="application_team-consumer" + cd examples/command/portals/kafka/instaclustr/docker + ./run.sh >/dev/null & + BGPID=$! + trap 'kill $BGPID; exit' INT + + run_success wait_till_container_starts "$container_to_watch" "900s" + + exit_on_successful "$container_to_watch" & + + wait_till_successful_run_or_error "$container_to_watch" + assert_equal "$exit_code" "0" +} + +@test "examples - kafka - redpanda docker" { + container_to_watch="application_team-consumer" + + cd examples/command/portals/kafka/redpanda/docker + ./run.sh >log.txt & + BGPID=$! + trap 'kill $BGPID; exit' INT + + run_success wait_till_container_starts "$container_to_watch" + + exit_on_successful "$container_to_watch" & + + wait_till_successful_run_or_error "$container_to_watch" + assert_equal "$exit_code" "0" +} + +@test "examples - kafka - warpstream serverless" { + export EXTRA_ARG="$WARPSTREAM_API_KEY" + container_to_watch="application_team-consumer" + + cd examples/command/portals/kafka/warpstream + ./run.sh $WARPSTREAM_API_KEY >/dev/null & + BGPID=$! + trap 'kill $BGPID; exit' INT + + run_success wait_till_container_starts "$container_to_watch" + + exit_on_successful "$container_to_watch" & + + wait_till_successful_run_or_error "$container_to_watch" + assert_equal "$exit_code" "0" +} diff --git a/implementations/rust/ockam/ockam_command/tests/bats/examples/setup.bash b/implementations/rust/ockam/ockam_command/tests/bats/examples/setup.bash new file mode 100644 index 00000000000..bb5e72c4814 --- /dev/null +++ b/implementations/rust/ockam/ockam_command/tests/bats/examples/setup.bash @@ -0,0 +1,58 @@ +#!/bin/bash + +wait_till_container_starts() { + container_to_listen_to="$1" + timeout=$2 + if [[ -z $timeout ]]; then + timeout="250s" + fi + + timeout "$timeout" bash </dev/null || continue + break + done +EOT +} + +wait_till_successful_run_or_error() { + container_to_listen_to="$1" + # Wait till consumer exits and grab the exit code + consumer_exit_code=$(docker wait "$container_to_listen_to") + + if [ "$consumer_exit_code" -eq 137 ]; then + exit_code=0 + return + fi + + exit_code=$consumer_exit_code +} + +exit_on_successful() { + container_to_listen_to="$1" + while true; do + logs=$(docker logs "$container_to_listen_to") + if [[ "$logs" == *"The example run was successful 🥳."$'\n'* ]]; then + docker stop "$container_to_listen_to" + return + fi + sleep 1 + done +} + +wait_till_pod_starts() { + pod_to_listen_to="$1" + timeout=$2 + if [[ -z $timeout ]]; then + timeout="250s" + fi + + timeout "$timeout" bash </dev/null || continue + break + done +EOT +}