-
Notifications
You must be signed in to change notification settings - Fork 42
/
deploy-tools
executable file
·69 lines (61 loc) · 1.57 KB
/
deploy-tools
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/usr/bin/env bash
set -uo pipefail
build-image()
{
docker build -t spoke:build .
}
install-deps()
{
yarn install --ignore-scripts --non-interactive --frozen-lockfile
}
build-app()
{
yarn run prod-build
}
extract-artifacts()
{
rm -rf ../spoke-dependencies-layer
local CONTAINER_ID=$(docker run -d spoke:build false)
docker cp $CONTAINER_ID:/spoke ../spoke-dependencies-layer
docker rm $CONTAINER_ID
}
preflight()
{
sls invoke -f preflight -s $STAGE
}
deploy()
{
# TODO: change this to whatever s3 bucket you want to use for your public assets. The bucket must have CORS
# enabled. This s3 bucket should be served from the ASSET_DOMAIN configured in your serverless.yml -- you can
# either set ASSET_DOMAIN to the s3 website hosting URL for the bucket, or configure CloudFront or another CDN
# to front this bucket and use your CDN domain as your ASSET_DOMAIN.
#
# Make sure your CDN preserves the CORS headers! Instructions for doing that for CloudFront
# are here: https://aws.amazon.com/premiumsupport/knowledge-center/no-access-control-allow-origin-error/
aws s3 cp ./build/client/assets s3://ew-spoke-public/$STAGE/assets/ --acl public-read --recursive --cache-control max-age=604800
sls create_domain -s $STAGE
sls deploy -s $STAGE
}
case "$1" in
build-image)
build-image "${@:2}"
;;
install-deps)
install-deps "${@:2}"
;;
build-app)
build-app "${@:2}"
;;
extract-artifacts)
extract-artifacts "${@:2}"
;;
preflight)
preflight "${@:2}"
;;
deploy)
deploy "${@:2}"
;;
*)
exec "$@"
;;
esac