-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdeploy.sh
executable file
·26 lines (20 loc) · 1.03 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
#!/usr/bin/env bash
export DOCKER_VERSION=${DOCKER_VERSION:-$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1)} # force redeployment on changes
export DOCKER_IMAGE=${DOCKER_IMAGE:-turiphro/fargate-blog}:$DOCKER_VERSION
echo " > Steps to perform:"
echo " > 1. build & push Docker container [container stack] - $DOCKER_IMAGE"
echo " > 2. build & deploy SAM / CloudFormation stack [both stacks]"
echo " > 3. get output URLs, save to file [both stacks]"
echo " > 4. open/upload static website [both stacks]"
## Build & push docker container
docker build -t $DOCKER_IMAGE .
docker push $DOCKER_IMAGE
## Build & deploy full stack
sam build
sam deploy --parameter-overrides "ParameterKey=DockerImage,ParameterValue=$DOCKER_IMAGE"
## Save URLs
RAW_OUTPUTS=$(aws cloudformation describe-stacks --stack-name sam-app --query "Stacks[0].Outputs")
echo "let urls = $RAW_OUTPUTS" > html/urls.js
## Open the demo file
echo "SUCCESS!"
echo "Now open or refresh file://$PWD/html/index.html"