Skip to content

LocalTesting

Ville Salmela edited this page Oct 21, 2023 · 1 revision

"Local" Testing

While you can run the web app and database locally, some components don't currently have local options. If you really want to do the work, here is how:

  1. Install Docker Engine
  2. Install Visual Studio Code
  3. Install Dev Containers extension
  4. Setup a PostgreSQL server
    • ENV: DB_HOST, DB_PORT, DB_PASSWORD, DB_USER, DB_NAME
  5. Create a new AWS VPC, which will be used to isolate the lambda function
    • Give it one subnet, and no access to other networks
  6. Create a new AWS Lambda function
    • ENV: PYTEST_REGION
    • Attach the lambda function to the newly created VPC
    • Modify the automatically created execution role, which the lambda function will assume
      • Set the role to have one policy, AWSDenyALL.
        This will limit any damage that can occur if malicious user manages to escape isolation.
    • Upload the code for the lambda function
    • Create a resource based policy that allows invoking this lambda function
    • Create a user, and assign it the policy you just created
  7. Setup OpenAI API key
    • ENV: OPENAI_API_KEY
  8. Setup Mailjet account
  9. Clone this project to your workstation
  10. Change directory to project root
  11. Copy the template for environment variables from this template
    • Paste the template values in a new file, located in .devcontainer/devcontainer.env
    • Place secret values in the newly created file
  12. In VS Code, press F1
  13. Enter command >dev containers: open folder in container
    • Select the project root folder
    • This will build and start the image
  14. Change to app directory
  15. Run gunicorn -c gunicorn_config.py qcl:app

Clone this wiki locally