-
Notifications
You must be signed in to change notification settings - Fork 0
/
deploy.sh
executable file
·31 lines (23 loc) · 1 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
29
30
31
#!/bin/bash
env="$1"
# incase we want to have multiple stages in the future
if [ $env != "prd" ] && [ $env != "test" ] && [ $env != "dev" ]; then
echo "Unknown env $env, valid envs are prd or test"
exit 1
fi
# this is where we compress any JS and CSS files
rm -rf stage
mkdir stage
cp -r ./dist-pages/* ./stage
bucket="s3://upr-dapp"
echo $bucket;
# GZIP encode every css and js files then rename them to remove the .gz ext
find ./stage/*.js -exec gzip -9 {} \; -exec mv {}.gz {} \;
find ./stage/*.css -exec gzip -9 {} \; -exec mv {}.gz {} \;
# Add 1yr cache to Assets
aws s3 sync ./stage "$bucket" --include "*" --exclude "*.css" --exclude "*.js" --exclude "*.html" --cache-control "max-age=31536000"
# Add 1 year cache to CSS and JS
aws s3 sync ./stage "$bucket" --exclude "*" --include "*.js" --include "*.css" --content-encoding gzip --cache-control "max-age=31536000"
# Add 2min cache to main html file
aws s3 sync ./stage "$bucket" --exclude "*" --include "*.html" --cache-control "max-age=120"
rm -rf ./stage