GithubHelp home page GithubHelp logo

ecommerce-microservice's Introduction

Setup

To launch the end-to-end microservices application perform the following:

Step 1.

Navigate into the [frontend] directory, and confirm the presence of the docker-compose.deploy.yml file:

cd frontend
ls -la

Step 1.

Create a new Docker network and name it micro_network:

docker network create micro_network

Step 2.

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

Step 3.

Launch the microservice environment:

docker-compose -f docker-compose.deploy.yml build
docker ps -a

Step 4.

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

Step 5.

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

Step 6.

Using your workstations browser - navigate to the following URL and register:

http://localhost:5000/register

Step 7.

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

Step 8.

Using your workstations browser - login, and add products into your cart, and then finally click the checkout option

http://localhost:5000/login

Step 9.

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

Microservices Teardown

Perform the following steps

Step 1.

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

Step 2.

Remove the container volumes

for vol in frontend_orderdb_vol frontend_productdb_vol frontend_userdb_vol;
do
 docker volume rm $vol
done

Step 3.

Remove the container network

docker network rm micro_network

ecommerce-microservice's People

Contributors

knight069 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.