How to use Docker locally to run a copy of the Prod Database - SeedCompany/cord-docs GitHub Wiki
-
First go to the root folder of your
cord-api-v3
project in the terminal -
Next make sure you have a sibling file in
cord-api-v3
at the root level called "docker-compose.override.yml" with the following contentsversion: '3.7' services: db: # Mount and persist database data volumes: - ./data:/var/lib/neo4j/data # memory Settings environment: NEO4J_dbms_memory_transaction_total_max: 2.0GB
-
Start the db using
docker-compose up db
; if this works then you have a working container (otherwise troubleshoot) -
Stop the db using
docker-compose down
. You can open a second terminal to do this or presscontrol + c
in the current terminal and then run the command -
In order to do the next step, you will need the AWSCLI installed. Can run
brew list
in your terminal to verify it's installed. After installing then you can copy an old version of the db down from AWS by running the script below (copy and paste in your terminal) ; make sure you replace the two instances of {ask_for_path} below with the real path after asking another dev for itdumps=./data/dumps latestBackupPath=$(aws s3 ls s3://{ask_for_path}/ --recursive | sort | tail -n 1 | awk '{ print $4 }') backupFile=$(basename $latestBackupPath) aws s3 cp s3://{ask_for_path}/$latestBackupPath $dumps/$backupFile
-
Run the following command to unzip the file and expose the
.backup
file neededtar -xf $dumps/*.tar.gz -C $dumps
-
View the
/data/dumps
directory to verify that your.backup
file is there; it should look something like this:neo4j-0000-00-00T00-00-00.backup
-
Run the following to start a NEO4J shell
dco run db /bin/bash
-
Run the following script to extract the copied db and restore it within your docker db instance; make sure to replace {filename} below with the actual filename from your /data/dumps directory
bin/neo4j-admin database restore --overwrite-destination=true --from-path=./data/dumps/{filename}.backup neo4j
-
Note this last step could take up to 30 minutes or so depending on your local environment
-
After this completes you can type
exit
to leave the neo4j shell -
Run the following to remove the copy from the
/data/dumps
directoryrm -rf $dumps/*
-
Now you can fire up the database within your Docker container
docker-compose up db
-
At this point you should be able to start
cord-api-v3
andcord-field
successfully, and then log into your localhost as admin