Skip to content

Commit

Permalink
fix: apply the mongo settings properly #10
Browse files Browse the repository at this point in the history
  • Loading branch information
ymarcon committed May 8, 2024
1 parent 82442dc commit 64db5ad
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 19 deletions.
23 changes: 23 additions & 0 deletions bin/first_run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,29 @@ anonympw=$(echo -n $MICA_ANONYMOUS_PASSWORD | xargs java -jar /usr/share/mica2/t
cat $MICA_HOME/conf/shiro.ini | sed -e "s/^anonymous\s*=.*/anonymous=$anonympw/" > /tmp/shiro.ini && \
mv /tmp/shiro.ini $MICA_HOME/conf/shiro.ini

# Configure MongoDB
if [ -n "$MONGODB_URI" ]
then
sed s,localhost:27017/mica,$MONGODB_URI,g $MICA_HOME/conf/application.yml > /tmp/application.yml
mv -f /tmp/application.yml $MICA_HOME/conf/application.yml
elif [ -n "$MONGO_HOST" ]
then
MGP=27017
if [ -n "$MONGO_PORT" ]
then
MGP=$MONGO_PORT
fi
MGURI="$MONGO_HOST:$MGP"
if [ -n "$MONGO_USER" ] && [ -n "$MONGO_PASSWORD" ]
then
MGURI="$MONGO_USER:$MONGO_PASSWORD@$MGURI/$MONGO_DB?authSource=admin"
else
MGURI="$MGURI/$MONGO_DB"
fi
sed s,localhost:27017/mica,$MGURI,g $MICA_HOME/conf/application.yml > /tmp/application.yml
mv -f /tmp/application.yml $MICA_HOME/conf/application.yml
fi

# Configure Opal
if [ -n "$OPAL_HOST" ]
then
Expand Down
20 changes: 7 additions & 13 deletions bin/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,13 @@ if [ -e /opt/mica/bin/first_run.sh ]
mv /opt/mica/bin/first_run.sh /opt/mica/bin/first_run.sh.done
fi

if [ -z $MONGODB_URI ]
then
#https://docs.spring.io/spring-boot/docs/1.5.6.RELEASE/reference/html/boot-features-external-config.html#boot-features-external-config
# According to spring documentation ENV vars have precede before application.yaml properties, so we just set the value instead of fiddling with the yml file
if [ -n "$MONGO_USERNAME" ] && [ -n "$MONGO_PASSWORD" ]
then
export SPRING_DATA_MONGODB_URI=mongodb://$MONGO_USERNAME:$MONGO_PASSWORD@${MONGO_HOST:-mongo}:${MONGO_PORT:-27017}/${MONGO_DB:-mica}?authSource=admin
else
export SPRING_DATA_MONGODB_URI=mongodb://${MONGO_HOST:-mongo}:${MONGO_PORT:-27017}/${MONGO_DB:-mica}
fi
else
export SPRING_DATA_MONGODB_URI=$MONGODB_URI
fi
# Wait for MongoDB to be ready
if [ -n "$MONGO_HOST" ]
then
until curl -i http://$MONGO_HOST:$MONGO_PORT/mica &> /dev/null
do
sleep 1
done

# Start mica
/usr/share/mica2/bin/mica2
17 changes: 11 additions & 6 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
version: '3'
services:
mica:
image: obiba/mica
Expand All @@ -13,17 +12,17 @@ services:
- MONGO_HOST=mongo
- MONGO_PORT=27017
- MONGO_DB=mica
# - MONGO_USERNAME=mica
# - MONGO_PASSWORD=${MICA_ADMINISTRATOR_PASSWORD}
- MONGO_USER=${MONGO_USER:-obiba}
- MONGO_PASSWORD=${MONGO_PASSWORD:-password}
- OPAL_URL=http://opal:8080
- AGATE_URL=http://agate:8081
volumes:
- /tmp/mica:/srv
mongo:
image: mongo:6.0
# environment:
# - MONGO_INITDB_ROOT_USERNAME=mica
# - MONGO_INITDB_ROOT_PASSWORD=${MICA_ADMINISTRATOR_PASSWORD}
environment:
- MONGO_INITDB_ROOT_USERNAME=${MONGO_USER:-obiba}
- MONGO_INITDB_ROOT_PASSWORD=${MONGO_PASSWORD:-password}
opal:
image: obiba/opal
ports:
Expand All @@ -34,6 +33,9 @@ services:
- OPAL_ADMINISTRATOR_PASSWORD=password
- MONGO_HOST=mongo
- MONGO_PORT=27017
- MONGO_USER=${MONGO_USER:-obiba}
- MONGO_PASSWORD=${MONGO_PASSWORD:-password}
- MONGODATA_DATABASE=opal
- AGATE_URL=http://agate:8081
volumes:
- /tmp/opal:/srv
Expand All @@ -47,6 +49,9 @@ services:
- AGATE_ADMINISTRATOR_PASSWORD=password
- MONGO_HOST=mongo
- MONGO_PORT=27017
- MONGO_DB=agate
- MONGO_USER=${MONGO_USER:-obiba}
- MONGO_PASSWORD=${MONGO_PASSWORD:-password}
- RECAPTCHA_SITE_KEY=6Lfo7gYTAAAAAOyl8_MHuH-AVBzRDtpIuJrjL3Pb
- RECAPTCHA_SECRET_KEY=6Lfo7gYTAAAAADym-vSDvPBeBCXaxIprA0QXLk_b
volumes:
Expand Down

0 comments on commit 64db5ad

Please sign in to comment.