Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions scripts/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# generated key file, for mongodb auth
# avoid pushing to repo
mongod_key
4 changes: 4 additions & 0 deletions scripts/mongod.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
security:
keyFile: /etc/mymongo/mongod_key
replication:
replSetName: "rs0"
21 changes: 20 additions & 1 deletion scripts/run-mongodb-dev.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,23 @@

set -ex

sudo docker run -d --network host --name mongodb -e MONGO_INITDB_ROOT_USERNAME=root -e MONGO_INITDB_ROOT_PASSWORD=password mongo:8.0.6
SCRIPT_DIR=$(dirname $0)

if test -e "$SCRIPT_DIR/mongod.conf"
then
CONFIG_FLAG="--config /etc/mymongo/mongod.conf"
VOLUME_FLAG="-v $SCRIPT_DIR:/etc/mymongo"

if test -e "$SCRIPT_DIR/mongod_key"
then
echo "skipping key generation"
else
openssl rand -base64 756 > $SCRIPT_DIR/mongod_key
chmod 400 $SCRIPT_DIR/mongod_key
fi
sudo chown 999:999 $SCRIPT_DIR/mongod_key
fi

sudo docker run -d --network host --name mongodb ${VOLUME_FLAG} -e MONGO_INITDB_ROOT_USERNAME=root -e MONGO_INITDB_ROOT_PASSWORD=password mongo:8.0.6 ${CONFIG_FLAG}
sleep 10
sudo docker exec -i mongodb mongosh -u root -p password --eval 'rs.initiate()'