-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdeploy
executable file
·45 lines (36 loc) · 1.5 KB
/
deploy
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
#!/usr/bin/env bash
# requirements:
# - login to aws
# - login to aws ecr docker
set -e
if [[ -z "${AWS_PROFILE}" ]]; then
echo "You must set the AWS_PROFILE environment variable to the name of your profile. Often this is data-infrastructure-prod."
exit 1
else
echo "Using AWS profile $AWS_PROFILE"
fi
if [ "$1" == "dev" ]; then
environment=analysisworkspace-dev
elif [ "$1" == "staging" ]; then
environment=data-workspace-staging
elif [ "$1" == "prod" ]; then
environment=jupyterhub
else
echo "Argument not recognised - valid args are 'dev', 'staging' and 'prod'."
exit 1
fi
account_id=$(aws sts get-caller-identity --query Account --output text)
echo "Logging into ECR"
aws ecr get-login-password --region eu-west-2 | docker login --username AWS --password-stdin $account_id.dkr.ecr.eu-west-2.amazonaws.com
echo "Building docker image"
if [ "$(uname)" == "Darwin" ]; then
DOCKER_DEFAULT_PLATFORM=linux/amd64 docker build -t superset:latest -f Dockerfile .
else
docker build -t superset:latest -f Dockerfile .
fi
echo "Pushing docker image to ECR for $1"
docker tag superset:latest $account_id.dkr.ecr.eu-west-2.amazonaws.com/$environment-superset:master
docker push $account_id.dkr.ecr.eu-west-2.amazonaws.com/$environment-superset:master
echo "Triggering redeployment of webserver for $1"
aws ecs update-service --cluster $environment --service $environment-superset --force-new-deployment > /dev/null
echo "Done. Note that the redeployment is asynchronous, and will take a few minutes to complete."