-
Notifications
You must be signed in to change notification settings - Fork 48
Expand file tree
/
Copy pathdeploy.sh
More file actions
executable file
·27 lines (20 loc) · 837 Bytes
/
deploy.sh
File metadata and controls
executable file
·27 lines (20 loc) · 837 Bytes
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
#!/usr/bin/env bash
set -u
if [ ! -v AWS_SESSION_TOKEN ]; then
source ./scripts/switch-role.sh
fi
readonly DOCKER_NAME=micropost/frontend
readonly AWS_ACCOUNT_NUMBER=$(aws sts get-caller-identity --output text --query 'Account')
readonly IMAGE_URL=${AWS_ACCOUNT_NUMBER}.dkr.ecr.${AWS_DEFAULT_REGION}.amazonaws.com/${DOCKER_NAME}
# Build
PUBLIC_PATH="https://cdn-${ENV}.hana053.com" yarn run build
# Ensure docker repository exists
aws ecr describe-repositories --repository-names ${DOCKER_NAME} > /dev/null 2>&1 || \
aws ecr create-repository --repository-name ${DOCKER_NAME}
# Push to docker repository
eval $(aws ecr get-login)
docker build -t ${DOCKER_NAME} .
docker tag ${DOCKER_NAME}:latest ${IMAGE_URL}:latest
docker push ${IMAGE_URL}:latest
# Deploy
./scripts/ecs-deploy -c micropost -n frontend -i ${IMAGE_URL}:latest