katefike / sage

A personal finance app that's like Mint, but better. It uses a dockerized postfix/dovecot email server. Parses transaction data from alert emails.
MIT License
5 stars 0 forks source link

Deploy Sage for real #94

Closed katefike closed 4 months ago

katefike commented 1 year ago

TESTING

Dev

  1. Remove containers and images: docker rm -vf $(docker ps -aq) && docker rmi -f $(docker images -aq)

  2. Delete DB volume and remake it:

    (.venv) kfike@pop-os:~/Projects/sage$ sudo rm -r /var/lib/docker/volumes/sage_db/
    [sudo] password for kfike: 
    (.venv) kfike@pop-os:~/Projects/sage$ sudo mkdir /var/lib/docker/volumes/sage_db/
    (.venv) kfike@pop-os:~/Projects/sage$ sudo mkdir /var/lib/docker/volumes/sage_db/_data
  3. docker compose -f docker-compose.dev.yml up --build

  4. pytest -xv

    ========================================= 87 passed in 26.98s =========================================

    Prod

  5. Turn off the droplet.

  6. Detach the two volumes from the original droplet.

  7. Detach the reserved IP from the original droplet.

  8. Take a final snapshot of the original droplet: prod-24041801-test-deletion

  9. Delete the droplet and the firewall.

  10. Create a new droplet. Run bash setup/2_create_prod_server.sh

  11. Note that two reserved IPs will be created. Unassign and delete the new one.

  12. Assign the existing reserved IP to the new droplet.

  13. Attach the volumes to the new droplet.

  14. Ensure the the local .env has the correct values for prod

  15. Run bash setup/3_configure_prod_server.sh

  16. SSH to the host and run commands to mount the volumes: https://github.com/katefike/sage/issues/129#issuecomment-2106276472

  17. Send a test email. python3 scripts/get_all_emails.py ✔️

  18. Run sage. python3 -m sage ✔️

image

katefike commented 1 year ago

Related Issues

katefike commented 4 months ago

Local Development pytest Error and Solution

=============================================== ERRORS ================================================
______________________ ERROR collecting tests/test_parsers/test_email_parser.py _______________________
tests/test_parsers/test_email_parser.py:182: in <module>
    DATA = get_test_data()
tests/test_parsers/test_email_parser.py:166: in get_test_data
    msgs = utils.get_inbox_emails(uid)
tests/utils.py:50: in get_inbox_emails
    with imap_tools.MailBoxUnencrypted(ENV["IMAP4_FQDN"]).login(
.venv/lib/python3.10/site-packages/imap_tools/mailbox.py:68: in login
    self.folder.set(initial_folder)
.venv/lib/python3.10/site-packages/imap_tools/folder.py:44: in set
    check_command_status(result, MailboxFolderSelectError)
.venv/lib/python3.10/site-packages/imap_tools/utils.py:46: in check_command_status
    raise exception(command_result=command_result, expected=expected)
E   imap_tools.errors.MailboxFolderSelectError: Response status "OK" expected, but "NO" received. Data: [b'[SERVERBUG] Internal error occurred. Refer to server log for more information. [2024-05-20 22:32:12] (0.001 + 0.000 secs).']
------------------------------------------- Captured stdout -------------------------------------------
Recreated Maildir/.
Successfully loaded emails from mbox file.
------------------------------------------- Captured stderr -------------------------------------------
mkdir: cannot create directory ‘/home/kfike/Maildir/’: File exists
Fatal: Source is not an mbox file or a directory!
chmod: cannot access '/home/kfike/Maildir/': No such file or directory
======================================= short test summary info =======================================
ERROR tests/test_parsers/test_email_parser.py - imap_tools.errors.MailboxFolderSelectError: Response status "OK" expected, but "NO" received. Data...
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! stopping after 1 failures !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
========================================== 1 error in 0.35s ===========================================

Double check that the .mbox files exist in docker/mailserver/test_data/example_data