-
Notifications
You must be signed in to change notification settings - Fork 1
/
deploy.sh
executable file
·70 lines (56 loc) · 1.4 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
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
70
#!/bin/bash
environment="$1"
architecture="$2"
if [ -z "$environment" ]
then
echo "Usage: deploy.sh <environment> <architecture>"
echo "architecture must be 'arm64' or 'x86_64'"
exit 1
fi
if [ -z "$architecture" ]
then
echo "Usage: deploy.sh <environment> <architecture>"
echo "architecture must be 'arm64' or 'x86_64'"
exit 1
fi
compiler_arch=$architecture
if [ $architecture = "arm64" ]
then
compiler_arch="aarch64"
fi
rustup target add "$compiler_arch-unknown-linux-musl"
if [ $? -ne 0 ]
then
echo "rustup target add failed"
exit 1
fi
echo -e "\n+++++ Starting deployment +++++\n"
rm -rf ./bin
mkdir ./bin
mkdir ./bin/render
echo "+++++ build rust packages +++++"
cd rust/render
TARGET_CC="$compiler_arch-linux-musl-gcc" \
RUSTFLAGS="-C linker=$compiler_arch-linux-musl-gcc" \
cargo build --release --target "$compiler_arch-unknown-linux-musl"
if [ $? -ne 0 ]
then
echo "cargo build failed"
exit 1
fi
cp "target/$compiler_arch-unknown-linux-musl/release/render" ../../bin/render/bootstrap
echo "+++++ apply terraform +++++"
cd ../../terraform
terraform init
if [ $? -ne 0 ]
then
echo "terraform init failed"
exit 1
fi
terraform workspace new $environment
terraform workspace select $environment
aws_region="us-east-1"
terraform apply --auto-approve \
--var "aws_region=$aws_region" \
--var "architecture=$architecture"
echo -e "\n+++++ Deployment done +++++\n"