Pand-Aid / pandaid-api

backend for Pand-Aid pandemic response app
3 stars 3 forks source link

Znmeb issue 6 persist database #12

Closed znmeb closed 4 years ago

znmeb commented 4 years ago

name: Issue #6 persist database as a Docker volume about: create a persistent database via a Docker volume

IMPORTANT: Please do not create a Pull Request without creating an issue first.

What does this do and why?

This is a revised fix for Issue #6. We have database persistence in the master branch but it was done with a host directory in the repository mounted into the database container. This causes data corrupution if someone accidentally or deliberately changes that directory.

See issue #6

Additional notes for reviewers

None

Pre-Review Tasks

Place an ‘x’ between the brackets.

[ ] I wrote tests covering these changes

[x] I reviewed my own PR before asking for review from others

[x] I added PR comments providing additional context for reviewers where appropriate, or calling attention to especially sensitive changes.

[x] If deps were added, I verified the licenses / no dependencies

Verification steps

  1. docker-compose up -d --build. This creates the images and containers.
  2. docker logs pandaid-api_web_1. This shows what the web server did to create the database.
  3. Verify that the API comes up on <localhost:8000]>.
  4. docker-compose down. This stops and deletes the containers and the network.
  5. docker volume list. This will list the volume pandaid-api_postgresql-data.
  6. docker-compose up -d. This creates a new network and containers.
  7. docker logs pandaid-api_web_1 again. Note that the web server did not have to re-create the database.
  8. Verify that the API still comes up on <localhost:8000>.