Avoid duplicate MONGODB_URL in env local (#659)

pull/667/head
jmformenti 2023-12-27 11:08:59 +01:00 committed by GitHub
parent a42f592aaf
commit e9e839d24f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 11 additions and 5 deletions

View File

@ -1,17 +1,23 @@
ENV_LOCAL_PATH=/app/.env.local
if test -z "${DOTENV_LOCAL}" ; then
if ! test -f "/app/.env.local" ; then
if ! test -f "${ENV_LOCAL_PATH}" ; then
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."
fi;
else
echo "DOTENV_LOCAL was found in the ENV variables. Creating .env.local file."
cat <<< "$DOTENV_LOCAL" > /app/.env.local
cat <<< "$DOTENV_LOCAL" > ${ENV_LOCAL_PATH}
fi;
if [ "$INCLUDE_DB" = "true" ] ; then
echo "INCLUDE_DB is set to true. Appending MONGODB_URL"
echo "INCLUDE_DB is set to true."
touch /app/.env.local
echo -e "\nMONGODB_URL=mongodb://localhost:27017" >> /app/.env.local
MONGODB_CONFIG="MONGODB_URL=mongodb://localhost:27017"
if ! grep -q "^${MONGODB_CONFIG}$" ${ENV_LOCAL_PATH}; then
echo "Appending MONGODB_URL"
touch /app/.env.local
echo -e "\n${MONGODB_CONFIG}" >> ${ENV_LOCAL_PATH}
fi
mkdir -p /data/db
mongod &