Skip to content

Commit

Permalink
upgrade to mongo 4.4.29. mongo seed to setup user powerbi
Browse files Browse the repository at this point in the history
  • Loading branch information
Laoujin committed Dec 26, 2024
1 parent bc050c2 commit cbd2a39
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 1 deletion.
3 changes: 3 additions & 0 deletions deploy/.env.sample
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ MONGO_USER=
MONGO_PWD=
MONGO_DB=confac

MONGO_POWERBI_USER=
MONGO_POWERBI_PWD=


# App
APP_PORT=7000
Expand Down
7 changes: 6 additions & 1 deletion deploy/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ version: '3'
services:
mongo:
container_name: confac-${ENVIRONMENT}-mongo
image: mongo:3.6.3
build:
context: ./mongo-seed
dockerfile: Dockerfile
restart: always
volumes:
- "${MONGO_DATA_VOLUME}:/data/db"
Expand All @@ -16,6 +18,9 @@ services:
environment:
MONGO_INITDB_ROOT_USERNAME: ${MONGO_USER}
MONGO_INITDB_ROOT_PASSWORD: ${MONGO_PWD}
MONGO_INITDB_DATABASE: ${MONGO_DB}
MONGO_POWERBI_USER: ${MONGO_POWERBI_USER}
MONGO_POWERBI_PWD: ${MONGO_POWERBI_PWD}


app:
Expand Down
7 changes: 7 additions & 0 deletions deploy/mongo-seed/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
FROM mongo:4.4.29

# Copy your sh file and adjust permissions:
COPY import.sh /docker-entrypoint-initdb.d
RUN chmod +x /docker-entrypoint-initdb.d/import.sh

CMD ["mongod"]
17 changes: 17 additions & 0 deletions deploy/mongo-seed/import.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
set -e

if [ -z "${MONGO_POWERBI_USER}" ]; then
exit 0
fi

mongo <<EOF
use $MONGO_INITDB_DATABASE
db.createUser({
user: '$MONGO_POWERBI_USER',
pwd: '$MONGO_POWERBI_PWD',
roles: [{
role: 'read',
db: '$MONGO_INITDB_DATABASE'
}]
})
EOF

0 comments on commit cbd2a39

Please sign in to comment.