-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sh
executable file
·40 lines (37 loc) · 916 Bytes
/
build.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
#!/usr/bin/env bash
export TF_DIR="$(pwd)/terraform"
export SITE_DIR="$(pwd)/src"
aws_profile="ltjjc"
aws_credentials="${HOME}/.aws"
terraform_image="hashicorp/terraform:light"
openssl_image="pgarrett/openssl-alpine"
tf(){
# Runs terraform in docker container
docker run -i -t -v "${TF_DIR}:/tf" -w /tf "${terraform_image}" "${@}"
}
init() {
tf
}
cert(){
docker run --rm -v "$(pwd)/Docker/certs:/etc/ssl/certs" "${openssl_image}"
}
plan(){
tf plan
}
apply(){
tf apply
}
push(){
domain=$(tf output -json | jq -r .website.value)
aws s3 sync --profile "${aws_profile}" --delete "${SITE_DIR}" "s3://${domain}"
#docker run -v "${aws_credentials}:/home/.aws":ro -v "${SITE_DIR}:/dist":ro -e "HOME=/home" "${terraform_image}" aws s3 sync --profile "${aws_profile}" --dry-run /dist "s3:${domain}"
}
deploy_infra(){
plan
apply
}
dev(){
cert
docker-compose up
}
"${@:-}"