From fbce304e9577f46d93dfc9ddfef425cf7b95b96c Mon Sep 17 00:00:00 2001 From: Jack Curtis Date: Wed, 10 Apr 2024 08:33:51 -0400 Subject: [PATCH 1/3] add bash script to simplify manual staging deployment --- bin/manual-app-deploy.sh | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 bin/manual-app-deploy.sh diff --git a/bin/manual-app-deploy.sh b/bin/manual-app-deploy.sh new file mode 100644 index 00000000..8b8857de --- /dev/null +++ b/bin/manual-app-deploy.sh @@ -0,0 +1,22 @@ +#!/bin/bash + +# Set the following environment variables to deploy to Staging: +# export CLUSTER_NAME: dpDashDevCluster +# export TASK_NAME: dpDashDevTaskDefinition +# export SERVICE_NAME: dpDashDevService + +AWS_ACCOUNT_ID=$(aws sts get-caller-identity --query "Account") + +docker build -t dpdash:latest . +aws ecr get-login-password --region us-east-1 | docker login --username AWS --password-stdin $AWS_ACCOUNT_ID.dkr.ecr.us-east-1.amazonaws.com + +ECR_IMAGE="$AWS_ACCOUNT_ID.dkr.ecr.us-east-1.amazonaws.com/dpdash:latest" + +docker tag dpdash:latest $ECR_IMAGE +docker push $ECR_IMAGE + +TASK_DEFINITION=$(aws ecs describe-task-definition --task-definition "$TASK_NAME" --region="us-east-1") +NEW_TASK_DEFINITION=$(echo $TASK_DEFINITION | jq --arg IMAGE "$ECR_IMAGE" '.taskDefinition | .containerDefinitions[0].image = $IMAGE | del(.taskDefinitionArn) | del(.revision) | del(.status) | del(.requiresAttributes) | del(.compatibilities) | del(.registeredAt) | del(.registeredBy)') +NEW_REVISION=$(aws ecs register-task-definition --region "us-east-1" --cli-input-json "${NEW_TASK_DEFINITION}") +NEW_REVISION_DATA=$(echo $NEW_REVISION | jq '.taskDefinition.revision') +aws ecs update-service --cluster "$CLUSTER_NAME" --service "$SERVICE_NAME" --task-definition "$TASK_NAME" --force-new-deployment From f659147c2e9687c170f6de294ef8ce8095ecc483 Mon Sep 17 00:00:00 2001 From: Jack Curtis Date: Wed, 10 Apr 2024 08:35:59 -0400 Subject: [PATCH 2/3] don't set unused vars --- bin/manual-app-deploy.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/bin/manual-app-deploy.sh b/bin/manual-app-deploy.sh index 8b8857de..3bbb826a 100644 --- a/bin/manual-app-deploy.sh +++ b/bin/manual-app-deploy.sh @@ -17,6 +17,5 @@ docker push $ECR_IMAGE TASK_DEFINITION=$(aws ecs describe-task-definition --task-definition "$TASK_NAME" --region="us-east-1") NEW_TASK_DEFINITION=$(echo $TASK_DEFINITION | jq --arg IMAGE "$ECR_IMAGE" '.taskDefinition | .containerDefinitions[0].image = $IMAGE | del(.taskDefinitionArn) | del(.revision) | del(.status) | del(.requiresAttributes) | del(.compatibilities) | del(.registeredAt) | del(.registeredBy)') -NEW_REVISION=$(aws ecs register-task-definition --region "us-east-1" --cli-input-json "${NEW_TASK_DEFINITION}") -NEW_REVISION_DATA=$(echo $NEW_REVISION | jq '.taskDefinition.revision') +aws ecs register-task-definition --region "us-east-1" --cli-input-json "${NEW_TASK_DEFINITION}" aws ecs update-service --cluster "$CLUSTER_NAME" --service "$SERVICE_NAME" --task-definition "$TASK_NAME" --force-new-deployment From 7bb73be3836d4374648ef0659f68ff73fe58e21f Mon Sep 17 00:00:00 2001 From: Jack Curtis Date: Mon, 6 May 2024 14:57:45 -0400 Subject: [PATCH 3/3] fix extra quotes in image tag --- bin/manual-app-deploy.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/manual-app-deploy.sh b/bin/manual-app-deploy.sh index 3bbb826a..465eb309 100644 --- a/bin/manual-app-deploy.sh +++ b/bin/manual-app-deploy.sh @@ -10,7 +10,7 @@ AWS_ACCOUNT_ID=$(aws sts get-caller-identity --query "Account") docker build -t dpdash:latest . aws ecr get-login-password --region us-east-1 | docker login --username AWS --password-stdin $AWS_ACCOUNT_ID.dkr.ecr.us-east-1.amazonaws.com -ECR_IMAGE="$AWS_ACCOUNT_ID.dkr.ecr.us-east-1.amazonaws.com/dpdash:latest" +ECR_IMAGE=$AWS_ACCOUNT_ID.dkr.ecr.us-east-1.amazonaws.com/dpdash:latest docker tag dpdash:latest $ECR_IMAGE docker push $ECR_IMAGE