Skip to content

Commit

Permalink
custom mongo image updated
Browse files Browse the repository at this point in the history
  • Loading branch information
SonOfLope committed Dec 26, 2023
1 parent 597577b commit 84e6b92
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 17 deletions.
7 changes: 5 additions & 2 deletions mongo/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
FROM mongo:latest
FROM mongo:6-jammy

COPY init-script.sh /docker-entrypoint-initdb.d/
ENV MONGO_INITDB_ROOT_USERNAME admin
ENV MONGO_INITDB_ROOT_PASSWORD secret
ENV MONGO_INITDB_DATABASE admin

ADD mongo-init.js /docker-entrypoint-initdb.d/
15 changes: 0 additions & 15 deletions mongo/init-script.sh

This file was deleted.

16 changes: 16 additions & 0 deletions mongo/mongo-init.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
db.auth(process.env.MONGO_INITDB_ROOT_USERNAME, process.env.MONGO_INITDB_ROOT_PASSWORD)

db = db.getSiblingDB('admin')

db.createUser({
user: process.env.MONGO_USER,
pwd: process.env.MONGO_PASSWORD,
roles: [
{
role: 'root',
db: 'admin',
},
],
});

db.dropUser(process.env.MONGO_INITDB_ROOT_USERNAME);

0 comments on commit 84e6b92

Please sign in to comment.