jmformenti commited on
Commit
e9e839d
1 Parent(s): a42f592

Avoid duplicate MONGODB_URL in env local (#659)

Browse files
Files changed (1) hide show
  1. entrypoint.sh +11 -5
entrypoint.sh CHANGED
@@ -1,17 +1,23 @@
 
 
1
  if test -z "${DOTENV_LOCAL}" ; then
2
- if ! test -f "/app/.env.local" ; then
3
  echo "DOTENV_LOCAL was not found in the ENV variables and .env.local is not set using a bind volume. We are using the default .env config."
4
  fi;
5
  else
6
  echo "DOTENV_LOCAL was found in the ENV variables. Creating .env.local file."
7
- cat <<< "$DOTENV_LOCAL" > /app/.env.local
8
  fi;
9
 
10
  if [ "$INCLUDE_DB" = "true" ] ; then
11
- echo "INCLUDE_DB is set to true. Appending MONGODB_URL"
12
 
13
- touch /app/.env.local
14
- echo -e "\nMONGODB_URL=mongodb://localhost:27017" >> /app/.env.local
 
 
 
 
15
 
16
  mkdir -p /data/db
17
  mongod &
1
+ ENV_LOCAL_PATH=/app/.env.local
2
+
3
  if test -z "${DOTENV_LOCAL}" ; then
4
+ if ! test -f "${ENV_LOCAL_PATH}" ; then
5
  echo "DOTENV_LOCAL was not found in the ENV variables and .env.local is not set using a bind volume. We are using the default .env config."
6
  fi;
7
  else
8
  echo "DOTENV_LOCAL was found in the ENV variables. Creating .env.local file."
9
+ cat <<< "$DOTENV_LOCAL" > ${ENV_LOCAL_PATH}
10
  fi;
11
 
12
  if [ "$INCLUDE_DB" = "true" ] ; then
13
+ echo "INCLUDE_DB is set to true."
14
 
15
+ MONGODB_CONFIG="MONGODB_URL=mongodb://localhost:27017"
16
+ if ! grep -q "^${MONGODB_CONFIG}$" ${ENV_LOCAL_PATH}; then
17
+ echo "Appending MONGODB_URL"
18
+ touch /app/.env.local
19
+ echo -e "\n${MONGODB_CONFIG}" >> ${ENV_LOCAL_PATH}
20
+ fi
21
 
22
  mkdir -p /data/db
23
  mongod &