This repository has been archived by the owner on Jul 26, 2023. It is now read-only.
forked from fititnt/uwazi-docker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
docker-entrypoint.sh
executable file
·40 lines (29 loc) · 1.94 KB
/
docker-entrypoint.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
#!/bin/sh
echo "uwazi-docker: IS_FIRST_RUN: $IS_FIRST_RUN"
DB_INITIALIZATION_PATH=/home/node/uwazi/blank_state/uwazi_development
DB_RESTORE_PATH=/home/node/uwazi/dump/uwazi_development
if [ "$IS_FIRST_RUN" = "true" ] ; then
echo "uwazi-docker: Enviroment variable IS_FIRST_RUN is true. Assuming need to install database from blank state"
echo "\n\nuwazi-docker: Deleting ${DBHOST:-mongo} ${DATABASE_NAME:-uwazi_development} MongoDB database"
mongo -host ${DBHOST:-mongo} ${DATABASE_NAME:-uwazi_development} --eval "db.dropDatabase()"
echo "\n\nuwazi-docker: Importing $DB_INITIALIZATION_PATH to ${DBHOST:-mongo} ${DATABASE_NAME:-uwazi_development} MongoDB database"
mongorestore -h ${DBHOST:-mongo} $DB_INITIALIZATION_PATH --db=${DATABASE_NAME:-uwazi_development}
echo "uwazi-docker: Applyng yarn reindex. This will use data from MongoDB to feed Elastic Search"
yarn reindex
echo "uwazi-docker: If no fatal errors occurred, you will not need to use this command again"
exit 0
elif [ "$UPGRADE" = "true" ] ; then
echo "\n\nuwazi-docker: Deleting ${DBHOST:-mongo} ${DATABASE_NAME:-uwazi_development} MongoDB database"
mongo -host ${DBHOST:-mongo} ${DATABASE_NAME:-uwazi_development} --eval "db.dropDatabase()"
echo "\n\nuwazi-docker: Importing $DB_RESTORE_PATH to ${DBHOST:-mongo} ${DATABASE_NAME:-uwazi_development} MongoDB database"
mongorestore -h ${DBHOST:-mongo} $DB_RESTORE_PATH --db=${DATABASE_NAME:-uwazi_development}
echo "uwazi-docker: Environment variable UPGRADE is true. performing reindex"
echo running yarn reindex
yarn migrate
echo running yarn migrate
yarn reindex
else
echo "uwazi-docker: Enviroment variable IS_FIRST_RUN is not true. Assume MongoDB and Elastic Search provide already are intialized"
echo "uwazi-docker: [protip] is possible to initialize (or reset o initial state) MongoDB and Elastic Search with enviroment variable IS_FIRST_RUN=true"
fi
yarn run-production