Skip to content

Commit e9e839d

Browse files
authored
Avoid duplicate MONGODB_URL in env local (#659)
1 parent a42f592 commit e9e839d

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

entrypoint.sh

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,23 @@
1+
ENV_LOCAL_PATH=/app/.env.local
2+
13
if test -z "${DOTENV_LOCAL}" ; then
2-
if ! test -f "/app/.env.local" ; then
4+
if ! test -f "${ENV_LOCAL_PATH}" ; then
35
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."
46
fi;
57
else
68
echo "DOTENV_LOCAL was found in the ENV variables. Creating .env.local file."
7-
cat <<< "$DOTENV_LOCAL" > /app/.env.local
9+
cat <<< "$DOTENV_LOCAL" > ${ENV_LOCAL_PATH}
810
fi;
911

1012
if [ "$INCLUDE_DB" = "true" ] ; then
11-
echo "INCLUDE_DB is set to true. Appending MONGODB_URL"
13+
echo "INCLUDE_DB is set to true."
1214

13-
touch /app/.env.local
14-
echo -e "\nMONGODB_URL=mongodb://localhost:27017" >> /app/.env.local
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
1521

1622
mkdir -p /data/db
1723
mongod &

0 commit comments

Comments
 (0)