-
Notifications
You must be signed in to change notification settings - Fork 0
LocalTesting
Ville Salmela edited this page Oct 21, 2023
·
1 revision
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:
- Install Docker Engine
- Install Visual Studio Code
- Install Dev Containers extension
- Setup a PostgreSQL server
- ENV: DB_HOST, DB_PORT, DB_PASSWORD, DB_USER, DB_NAME
- Create a new AWS VPC, which will be used to isolate the lambda function
- Give it one subnet, and no access to other networks
- 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.
- Set the role to have one policy, AWSDenyALL.
- 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
- Setup an access key
- ENV: PYTEST_KEY_ID, PYTEST_KEY_SECRET
- Setup OpenAI API key
- ENV: OPENAI_API_KEY
- Setup Mailjet account
- ENV: MJ_APIKEY_PUBLIC, MJ_APIKEY_SECRET
-
create a template for transactional email
- ENV: MJ_TEMPLATE_ID
- the template must:
- accept one variable: "VERIFICATION_CODE"
- include default subject and sender
- Clone this project to your workstation
- Change directory to project root
- 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
- Paste the template values in a new file, located in
- In VS Code, press F1
- Enter command
>dev containers: open folder in container- Select the project root folder
- This will build and start the image
- Change to
appdirectory - Run
gunicorn -c gunicorn_config.py qcl:app- This will make the app available at http://localhost:8000