-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdeploy.sh
50 lines (35 loc) · 1.1 KB
/
deploy.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/usr/bin/env sh
set -e
CLUSTER="vpcity-api-cluster"
IMAGE_TAG="awsdevops/api"
SERVICE="VpcityApiService"
TASK_DEFINITION="awsdevops-api-task-def"
IMAGE="$AWS_ACCOUNT_ID.dkr.ecr.$AWS_DEFAULT_REGION.amazonaws.com/$IMAGE_TAG:$CIRCLE_SHA1"
function push_to_registry () {
echo "pushing to registry"
# Build down new version of image
docker build --rm=false -t $IMAGE .
# login to ECR as CircleCI
eval $(aws ecr get-login --no-include-email --region $AWS_DEFAULT_REGION)
# Push image to ECR
docker push $IMAGE
}
function update_api_service () {
echo "updating api service"
# create updated task
node ./create-updated-task.js
# Register the new Task Definition with ECS
aws ecs register-task-definition \
--cli-input-json file://updated-task.json
# Update the service, in our cluster, with the new task definition
aws ecs update-service --cluster $CLUSTER --service $SERVICE \
--task-definition $TASK_DEFINITION
# remove temp file
rm -rf ./updated-task.json
}
# call both of the above functions
function update_ecs () {
push_to_registry
update_api_service
}
update_ecs