-
Notifications
You must be signed in to change notification settings - Fork 0
/
revision.sh
88 lines (72 loc) · 2.29 KB
/
revision.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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#!/bin/sh
# Author: Guilherme Dalmarco
# Email : [email protected]
# This script is used to start applications on docker
# You need environments variable GWA_ENVIRONMENT set for production/homolog
# By default (without GWA_ENVIRONMENT set) we run as "dev"
if [ -z "${GWA_ENVIRONMENT}" ]
then
GWA_ENVIRONMENT="dev"
fi
#
# PRODUCTION ENVIRONMENT RULES
#
f_run_prd() {
# AWS Parameter Store
#echo -ne "\n#\n# DOCKER INIT SCRIPT: RUNNING aws cli to get parameter values for ${ECS_ENVIRONMENT}.${ECS_APPLICATION} in ${AWS_REGION} \n#\n"
#aws ssm get-parameters --names ${ECS_ENVIRONMENT}.${ECS_APPLICATION} --with-decryption --region ${AWS_REGION} | jq --raw-output .Parameters[0].Value > .env
#source prd.env
for DOTENV_VAR in $(cat environments/prd.env)
do
export ${DOTENV_VAR}
echo "${DOTENV_VAR}"
done
export PYTHONPATH=$(pwd)
make db_revision m="Auto generate revision."
}
#
# HOMOLOG ENVIRONMENT RULES
#
f_run_hml() {
# AWS Parameter Store
#echo -ne "\n#\n# DOCKER INIT SCRIPT: RUNNING aws cli to get parameter values for ${ECS_ENVIRONMENT}.${ECS_APPLICATION} in ${AWS_REGION} \n#\n"
#aws ssm get-parameters --names ${ECS_ENVIRONMENT}.${ECS_APPLICATION} --with-decryption --region ${AWS_REGION} | jq --raw-output .Parameters[0].Value > .env
#source prd.env
for DOTENV_VAR in $(cat environments/hml.env)
do
export ${DOTENV_VAR}
echo "${DOTENV_VAR}"
done
export PYTHONPATH=$(pwd)
make db_revision m="Auto generate revision."
}
#
# LOCAL TESTES AND DEVELOPERS: YOU CAN CHANGE THIS FUNCTION AS YOU WISH
#
f_run_local() {
# AWS ESS Parameter Store
echo -ne "\n#\n# DOCKER INIT SCRIPT: RUNNING ${GWA_ENVIRONMENT}.${GWA_ENVIRONMENT} \n#\n"
echo -ne "\n# REMEMBER TO PASS ENV VARIABLES TO DOCKER RUN WITH: -e VAR1=\"FOO\" -e VAR2=\"BAR\" \n#\n"
for DOTENV_VAR in $(cat environments/dev.env)
do
export ${DOTENV_VAR}
done
export PYTHONPATH=$(pwd)
make db_revision m="Auto generate revision."
}
#
# DO NOT CHANGE THE CODE BELOW
#
echo -ne "\n\n##\n##\tRUNNING WITH GWA_ENVIRONMENT=\"${GWA_ENVIRONMENT}\"\n##\n\n"
if [ "${GWA_ENVIRONMENT}" == "prd" ]
then
f_run_prd
fi
if [ "${GWA_ENVIRONMENT}" == "hml" ]
then
f_run_hml
fi
if [ "${GWA_ENVIRONMENT}" == "dev" ]
then
f_run_local
fi