Skip to content

Commit

Permalink
Add scripts for local run
Browse files Browse the repository at this point in the history
  • Loading branch information
cowuake committed Oct 22, 2024
1 parent 5ee247a commit 66a22b3
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 14 deletions.
8 changes: 1 addition & 7 deletions run.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,8 @@ if (-not (Test-Path $env:SAMPLE_DATA_ARCHIVE_LOCATION)) {
# Copy the sample data archive to the MongoDB container
docker cp $env:SAMPLE_DATA_ARCHIVE_LOCATION "${env:MONGO_CONTAINER_NAME}:${env:SAMPLE_DATA_ARCHIVE_FINAL_LOCATION}"

# Drop all databases except for admin, config, and local
Set-Content env:DROP_COMMAND_1 "const dbNames = db.getMongo().getDBNames();"
Set-Content env:DROP_COMMAND_2 "const toBeDropped = dbNames.filter(name => !['admin', 'config', 'local'].includes(name));"
Set-Content env:DROP_COMMAND_3 "toBeDropped.forEach(name => db.getMongo().getDB(name).dropDatabase());"
docker exec $env:MONGO_CONTAINER_NAME mongosh --eval "$env:DROP_COMMAND_1 $env:DROP_COMMAND_2 $env:DROP_COMMAND_3"

# Restore the sample data archive in the MongoDB container
docker exec $env:MONGO_CONTAINER_NAME mongorestore --archive=$env:SAMPLE_DATA_ARCHIVE_FINAL_LOCATION
docker exec $env:MONGO_CONTAINER_NAME mongorestore --archive=$env:SAMPLE_DATA_ARCHIVE_FINAL_LOCATION --drop

# Announce that the initial data has been loaded successfully and provide the URL to access the FastLazyBee app
Write-Output "> Initial data loaded successfully!"
Expand Down
8 changes: 1 addition & 7 deletions run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,8 @@ fi
# Copy the sample data archive to the MongoDB container
docker cp $SAMPLE_DATA_ARCHIVE_LOCATION $MONGO_CONTAINER_NAME:/$SAMPLE_DATA_ARCHIVE_LOCATION

# Drop all databases except for admin, config, and local
DROP_COMMAND_1="const dbNames = db.getMongo().getDBNames();"
DROP_COMMAND_2="const toBeDropped = dbNames.filter(name => !['admin', 'config', 'local'].includes(name));"
DROP_COMMAND_3="toBeDropped.forEach(name => db.getMongo().getDB(name).dropDatabase());"
docker exec $MONGO_CONTAINER_NAME mongosh --eval "$DROP_COMMAND_1 $DROP_COMMAND_2 $DROP_COMMAND_3"

# Restore the sample data archive in the MongoDB container
docker exec $MONGO_CONTAINER_NAME mongorestore --archive=/$SAMPLE_DATA_ARCHIVE_LOCATION
docker exec $MONGO_CONTAINER_NAME mongorestore --archive=/$SAMPLE_DATA_ARCHIVE_LOCATION --drop

# Announce that the initial data has been loaded successfully and provide the URL to access the FastLazyBee app
echo "> Initial data loaded successfully!"
Expand Down

0 comments on commit 66a22b3

Please sign in to comment.