-
Notifications
You must be signed in to change notification settings - Fork 2
/
build.sh
executable file
·135 lines (118 loc) · 3.73 KB
/
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
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
132
133
134
135
#!/bin/sh
echo "Starting build"
DO_NOT_EDIT_LINE="# DO NOT EDIT BELOW THIS LINE. IT IS CREATED BY 'build.sh'"
# Variables for Local env
PROJECT_LOCATION=$(pwd -P)
MONGOD_CONF_LOCATION=$(pwd -P)/mongod.conf
DOTENV_CONFIG_PATH_FOR_API=.env
SPA_PORT=3000
API_PORT=8000
# Development build
if [ "$1" = "dev" ]
then
# Local env
if [ -e .env.development.local ]
then
sed -i.bak "/$DO_NOT_EDIT_LINE/q" .env.development.local
else
touch .env.development.local
if [ -e .env.development.local.example ]
then
cat .env.development.local.example >> .env.development.local
fi
fi
cat >> .env.development.local << EOF
$DO_NOT_EDIT_LINE
PROJECT_LOCATION=$PROJECT_LOCATION
MONGOD_CONF_LOCATION=$MONGOD_CONF_LOCATION
DOTENV_CONFIG_PATH_FOR_API=$DOTENV_CONFIG_PATH_FOR_API
SPA_PORT=$SPA_PORT
API_PORT=$API_PORT
EOF
# Env for Development
# These URLs should NOT have trailing slashes
REACT_APP_API_DATA_LOCATION=http://localhost:8000/api/entry
REACT_APP_API_SCHEMA_LOCATION=http://localhost:8000/api/schema
REACT_APP_API_UI_SCHEMA_LOCATION=http://localhost:8000/api/uischema
REACT_APP_API_LOGIN_LOCATION=http://localhost:8000/login
if [ -e .env.development ]
then
sed -i.bak "/$DO_NOT_EDIT_LINE/q" .env.development
else
touch .env.development
if [ -e .env.development.example ]
then
cat .env.development.example >> .env.development
fi
fi
cat >> .env.development << EOF
$DO_NOT_EDIT_LINE
REACT_APP_API_DATA_LOCATION=$REACT_APP_API_DATA_LOCATION
REACT_APP_API_SCHEMA_LOCATION=$REACT_APP_API_SCHEMA_LOCATION
REACT_APP_API_UI_SCHEMA_LOCATION=$REACT_APP_API_UI_SCHEMA_LOCATION
REACT_APP_API_LOGIN_LOCATION=$REACT_APP_API_LOGIN_LOCATION
EOF
else
# Production build
# Local env
if [ -e .env.production.local ]
then
sed -i.bak "/$DO_NOT_EDIT_LINE/q" .env.production.local
else
touch .env.production.local
if [ -e .env.production.local.example ]
then
cat .env.production.local.example >> .env.production.local
fi
fi
cat >> .env.production.local << EOF
$DO_NOT_EDIT_LINE
PROJECT_LOCATION=$PROJECT_LOCATION
MONGOD_CONF_LOCATION=$MONGOD_CONF_LOCATION
DOTENV_CONFIG_PATH_FOR_API=$DOTENV_CONFIG_PATH_FOR_API
SPA_PORT=$SPA_PORT
API_PORT=$API_PORT
EOF
# Env for Production
# These URLs should NOT have trailing slashes
REACT_APP_API_DATA_LOCATION=http://api.mappingviolence.org/api/entry
REACT_APP_API_SCHEMA_LOCATION=http://api.mappingviolence.org/api/schema
REACT_APP_API_UI_SCHEMA_LOCATION=http://api.mappingviolence.org/api/uischema
REACT_APP_API_LOGIN_LOCATION=http://api.mappingviolence.org/login
if [ -e .env.production ]
then
sed -i.bak "/$DO_NOT_EDIT_LINE/q" .env.production
else
touch .env.production
if [ -e .env.production.example ]
then
cat .env.production.example >> .env.production
fi
fi
cat >> .env.production << EOF
$DO_NOT_EDIT_LINE
REACT_APP_API_DATA_LOCATION=$REACT_APP_API_DATA_LOCATION
REACT_APP_API_SCHEMA_LOCATION=$REACT_APP_API_SCHEMA_LOCATION
REACT_APP_API_UI_SCHEMA_LOCATION=$REACT_APP_API_UI_SCHEMA_LOCATION
REACT_APP_API_LOGIN_LOCATION=$REACT_APP_API_LOGIN_LOCATION
EOF
fi
if [ -e .env ]
then
sed -i.bak "/$DO_NOT_EDIT_LINE/q" .env
else
touch .env
if [ -e .env.example ]
then
cat .env.example >> .env
fi
fi
if [ "$1" = "dev" ]
then
echo $DO_NOT_EDIT_LINE >> .env
cat .env.development .env.development.local | sed -e "s/$DO_NOT_EDIT_LINE//g" | sed -e "/^$/d" >> .env
else
echo $DO_NOT_EDIT_LINE >> .env
cat .env.production .env.production.local | sed -e "s/$DO_NOT_EDIT_LINE//g" | sed -e "/^$/d" >> .env
fi
echo "Build ended"