-
Notifications
You must be signed in to change notification settings - Fork 0
/
deploy.sh
executable file
·28 lines (23 loc) · 1.04 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
# deploy.sh
#! /bin/bash
SHA1=$1
mkdir ~/.aws/
touch ~/.aws/credentials
printf "aws_access_key_id = %s\naws_secret_access_key = %s\n" "$AWS_ACCESS_KEY_ID" "$AWS_SECRET_ACCESS_KEY" >> ~/.aws/credentials
touch ~/.aws/config
printf "region=eu-central-1\noutput=json" >> ~/.aws/config
# Push image to ECR
$(aws ecr get-login --region eu-central-1)
docker push $AWS_ACCOUNT_ID.dkr.ecr.eu-central-1.amazonaws.com/howl-docker-repo:$SHA1
# Create new Elastic Beanstalk version
EB_BUCKET=howl-deploy-bucket
DOCKERRUN_FILE=$SHA1-Dockerrun.aws.json
sed "s/<TAG>/$SHA1/" < Dockerrun.aws.json.template > $DOCKERRUN_FILE
aws s3 cp $DOCKERRUN_FILE s3://$EB_BUCKET/$DOCKERRUN_FILE --region eu-central-1
aws elasticbeanstalk create-application-version --application-name Howl-Backend \
--version-label $SHA1 --source-bundle S3Bucket=$EB_BUCKET,S3Key=$DOCKERRUN_FILE \
--region eu-central-1
# Update Elastic Beanstalk environment to new version
aws elasticbeanstalk update-environment --environment-name Sample-env \
--version-label $SHA1 \
--region eu-central-1