Repository navigation
Expand file tree
/
Copy pathconfigure
More file actions
executable file
·131 lines (99 loc) · 3.62 KB
/
Copy pathconfigure
File metadata and controls
executable file
·131 lines (99 loc) · 3.62 KB
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
#!/usr/bin/env fish
set -l command $argv[1]
function dotenv --description 'Load environment variables from .env file'
set -l envfile ".master-conf"
if [ (count $argv) -gt 0 ]
set envfile $argv[1]
end
if test -e $envfile
for line in (cat $envfile)
set -xg (echo $line | cut -d = -f 1) (echo $line | cut -d = -f 2-)
end
end
end
function clear
rm .env >/dev/null 2>&1
rm nginx-context/.env >/dev/null 2>&1
rm nginx-context/nginx.conf >/dev/null 2>&1
rm nginx-context/fullchain.pem >/dev/null 2>&1
rm nginx-context/privkey.pem >/dev/null 2>&1
rm server-context/.env >/dev/null 2>&1
rm server-context/wait-for-it.sh >/dev/null 2>&1
rm webapp-context/.env >/dev/null 2>&1
end
function compose_env
true >.env
echo POSTGRES_USER=$POSTGRES_USER >>.env
echo POSTGRES_PW=$POSTGRES_PW >>.env
echo POSTGRES_DB=$MODE >>.env
echo ELK_VERSION=$ELK_VERSION >>.env
echo ELASTIC_PW=$ELASTIC_PW >>.env
end
function server_env
true >server-context/.env
true >"server-context/wait-for-it.sh"
cat wait-for-it.sh >"server-context/wait-for-it.sh"
echo MODE=$MODE >>server-context/.env
echo EMAIL_USER=$EMAIL_USER >>server-context/.env
echo EMAIL_PW=$EMAIL_PW >>server-context/.env
echo APP_KEY=$APP_KEY >>server-context/.env
echo SALT=$SALT >>server-context/.env
echo JWT_KEY=$JWT_KEY >>server-context/.env
echo AUTH_TOKEN_EXPIRATION=$AUTH_TOKEN_EXPIRATION >>server-context/.env
echo GET_FEATURES_JOB_INTERVAL=$GET_FEATURES_JOB_INTERVAL >>server-context/.env
echo HEARTBEAT_MAX_INTERVAL=$HEARTBEAT_MAX_INTERVAL >>server-context/.env
echo POSTGRES_IP=$POSTGRES_IP >>server-context/.env
echo ELASTIC_IP=$ELASTIC_IP >>server-context/.env
echo ELASTIC_PW=$ELASTIC_PW >>server-context/.env
echo QUALTRICS_TOKEN=$QUALTRICS_TOKEN >>server-context/.env
echo QUALTRICS_USER=$QUALTRICS_USER >>server-context/.env
echo URL=https://$EXTERNAL_DOMAIN:5000 >>server-context/.env
echo APP_URL=https://$EXTERNAL_DOMAIN >>server-context/.env
echo APP_DOCKER_URL=$APP_DOCKER_URL >>server-context/.env
echo HOST=0.0.0.0 >>server-context/.env
echo PORT=5000 >>server-context/.env
echo GUNICORN_BIND=0.0.0.0:5000 >>server-context/.env
echo GUNICORN_WORKER_CLASS=$GUNICORN_WORKER_CLASS >>server-context/.env
echo GUNICORN_WORKERS=$GUNICORN_WORKERS >>server-context/.env
end
function webapp_env
true >webapp-context/.env
echo NEXT_GRAPHQL_PROXY_URI=https://$EXTERNAL_DOMAIN/api/graphql >>webapp-context/.env
echo GRAPHQL_URI=http://api:5000/graphql >>webapp-context/.env
echo API_URI=https://$EXTERNAL_DOMAIN/api >>webapp-context/.env
end
function nginx_conf
true >nginx-context/nginx.conf
cp fullchain.pem nginx-context/fullchain.pem
cp privkey.pem nginx-context/privkey.pem
export EXTERNAL_DOMAIN=$EXTERNAL_DOMAIN
envsubst '${EXTERNAL_DOMAIN}' <nginx.conf.template >nginx-context/nginx.conf
end
if test "$command" = "clear"
echo $command
clear
end
if test "$command" = "gen"
echo $command
dotenv
if not contains $MODE "dev" "staging" "prod"
echo Error MODE $MODE invalid
exit
end
clear
if test "$MODE" = "dev"
set EXTERNAL_DOMAIN localhost
set GET_FEATURES_JOB_INTERVAL 15
set APP_DOCKER_URL http://webapp:3000
set AUTH_TOKEN_EXPIRATION 600
else
set EXTERNAL_DOMAIN j4u.unil.ch
set GET_FEATURES_JOB_INTERVAL 600
set APP_DOCKER_URL http://webapp:3000
set AUTH_TOKEN_EXPIRATION 3600
end
compose_env
server_env
webapp_env
nginx_conf
end