To launch the end-to-end microservices application perform the following:
Navigate into the [frontend] directory, and confirm the presence of the docker-compose.deploy.yml
file:
cd frontend
ls -la
Create a new Docker network and name it micro_network
:
docker network create micro_network
Build each of the microservice Docker container images:
docker-compose -f docker-compose.deploy.yml build
docker-compose -f docker-compose.deploy.yml up -d
docker images
Launch the microservice environment:
docker-compose -f docker-compose.deploy.yml build
docker ps -a
Prepare each microservice mysql database:
for service in corder-service cproduct-service cuser-service;
do
docker exec -it $service flask db init
docker exec -it $service flask db migrate
docker exec -it $service flask db upgrade
done
Populate the product database:
curl -i -d "name=prod1&slug=prod1&image=product1.jpg&price=100" -X POST localhost:5002/api/product/create
curl -i -d "name=prod2&slug=prod2&image=product2.jpg&price=200" -X POST localhost:5002/api/product/create
Using your workstations browser - navigate to the following URL and register:
http://localhost:5000/register
Back within your terminal, use a mysql client to confirm that a new user registration record was created:
mysql --host=127.0.0.1 --port=32000 --user=cloudacademy --password=pfm_2020
mysql> show databases;
mysql> use user;
mysql> show tables;
mysql> select * from user;
mysql> exit
Using your workstations browser - login, and add products into your cart, and then finally click the checkout option
http://localhost:5000/login
Back within your terminal, use a mysql client to confirm that a new order has been created:
mysql --host=127.0.0.1 --port=32002 --user=cloudacademy --password=pfm_2020
mysql> show databases;
mysql> use order;
mysql> show tables;
mysql> select * from order.order;
mysql> select * from order.order_item;
mysql> exit
Perform the following steps
Create a new Docker network and name it micro_network
:
for container in cuser-service cproduct-service corder-service cproduct_dbase cfrontend-app cuser_dbase corder_dbase;
do
docker stop $container
docker rm $container
done
Remove the container volumes
for vol in frontend_orderdb_vol frontend_productdb_vol frontend_userdb_vol;
do
docker volume rm $vol
done
Remove the container network
docker network rm micro_network