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.7+ and install Poetry using one of the following commands (as instructed by the poetry documentation):
curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/install.python-poetry.org | python -(Invoke-WebRequest -Uri https://raw.githubusercontent.com/python-poetry/poetry/master/install.python-poetry.org -UseBasicParsing).Content | python -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.
This app uses a Trello board to store the items. You should set up a Trello board, with three lists for 'To Do', 'Doing' and 'Done'. Update your .env file with the board and list id's, as well as your Trello API Key and Token.
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.
Run the following command on the control node:
ansible-playbook ansible-playbook.yml -i ansible-inventory
To create the image, run the command:
docker build --target development --tag todo-app:dev .
Then to run the container, run:
docker run --env-file .env -p 8080:5000 --mount type=bind,source="$(pwd)"/todo_app,target=/app/todo_app todo-app:dev
You can then find the app on http://localhost:8080/
To create the image, run the command:
docker build --target production --tag todo-app:prod .
Then to run the container, run:
docker run -p 8080:8000 --env-file .env todo-app:prod
You can then find the app on http://localhost:8080/
Once the all dependencies have been installed, you can run all tests with:
$ poetry run pytestTo create the image, run
$ docker build --target test --tag my-test-image .then to run the tests, run
$ docker run my-test-image