If you are using GitPod for the project exercise (i.e. you cannot use your local machine) then you'll want to launch a VM using the following link. Note this VM comes pre-setup with Python & Poetry pre-installed.
The project uses poetry for Python to create an isolated environment and manage package dependencies. To prepare your system, ensure you have an official distribution of Python version 3.8+ and install Poetry using one of the following commands (as instructed by the poetry documentation):
curl -sSL https://install.python-poetry.org | python3 -(Invoke-WebRequest -Uri https://install.python-poetry.org -UseBasicParsing).Content | py -The project uses a virtual environment to isolate package dependencies. To create the virtual environment and install required packages, run the following from your preferred shell:
$ poetry installYou'll also need to clone a new .env file from the .env.template to store local configuration options. This is a one-time operation on first setup:
$ cp .env.template .env # (first time only)The .env file is used by flask to set environment variables when running flask run. This enables things like development mode (which also enables features like hot reloading when you make a file change). There's also a SECRET_KEY variable which is used to encrypt the flask session cookie.
In order to run the application, some setup is required to performed once in order to get the necessary Trello config setup.
Main thing to ensure is that you have a 'To Do' and 'Done' list on your board as the functionality of this app is dependent on that.
Steps are as follows:
- Create an account
- Generate API key and token
- Assign the values obtained to there corresponding variables in the .env file:
- TRELLO_API_KEY
- TRELLO_API_TOKEN
- TRELLO_BOARD_ID
Once the all dependencies have been installed, start the Flask app in development mode within the Poetry environment by running:
$ poetry run flask runYou should see output similar to the following:
* Serving Flask app "app" (lazy loading)
* Environment: development
* Debug mode: on
* Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
* Restarting with fsevents reloader
* Debugger is active!
* Debugger PIN: 226-556-590Now visit http://localhost:5000/ in your web browser to view the app.
Tests can be run from the terminal by running poetry run pytest
If you want to skip running the end-to-end tests, you can do this by running poetry run pytest tests. Similarly, if you only want to run the end-to-end tests, you can do this by running poetry run pytest tests_e2e
You can also run tests individually within VSCode by following the instructions on this page
Following instructions should be run on control node only
- Create a file called 'vault.yaml'
- Use the following as a template, but replace placeholders with actual values
trello_api_key: <trello_api_key>
trello_api_token: <trello_api_token>
trello_board_id: <trello_board_id>- Create a file called vault-pass and add a line with what you would like the pasword for the vault to be
- Execute the following to encrypt the vault.yaml file created during step 2
ansible-vault encrypt --vault-password-file vault-pass vault.yaml- Run the playbook with following command
ansible-playbook playbook.yaml -i inventory.ini --vault-password-file vault-pass- If you need to view the content of the vault, you can run the following to decrypt
ansible-vault decrypt --vault-password-file vault-pass vault.yaml- Build the image with the following command
docker build --target development --tag todo-app:dev . - The container can be run via 2 ways
- Using a docker command
docker run --env-file .env --publish 5000:80 --mount type=bind,source="$(pwd)"/todo_app,target=/app/todo_app/todo_app todo-app:dev - Using Docker Compose, which will also start test runners (this includes unit, integration and end-to-end tests) that will continously rerun tests when a change is detected Note that for docker compose to work you will require the test images to be created. This can either be done manually in a similar way to the previous step, or add '--build' to the below command
docker compose up
- Using a docker command
- Build the image with the following command
docker build --target production --tag todo-app:prod . - Run the container
docker run --env-file .env --publish 5000:80 todo-app:prod
If you wish to create a container, but not start the application itself to debug, the following command can be used. You can also connect the container to VSCode to debug through that
docker compose -f docker-compose-debug.yaml up