Skip to main contentCloud Native Reference Implementation

Deploy Storefront (Openliberty Version) locally on your machine

Introduction

Storefront is a simple shopping application that displays a catalog of antique computing devices, where users can search and buy products. It has a Web interface, and it relies on BFF (Backend for Frontend) services to interact with the backend services.

Pre-requisites:

For more details on installation, check this out.

Running the application locally

Let us now deploy all the microservices of our storefront one by one locally.

Deploy JAEGER

  • Deploy Jaeger as follows
docker run -d --name jaeger -e COLLECTOR_ZIPKIN_HTTP_PORT=9411 -p 5775:5775/udp -p 6831:6831/udp -p 6832:6832/udp -p 5778:5778 -p 16686:16686 -p 14268:14268 -p 9411:9411 jaegertracing/all-in-one:1.11

If it is successfully deployed, you will see something like below.

$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
df370368c115 jaegertracing/all-in-one:1.11 "/go/bin/all-in-one-…" 3 minutes ago Up 3 minutes 0.0.0.0:5775->5775/udp, 0.0.0.0:5778->5778/tcp, 0.0.0.0:9411->9411/tcp, 0.0.0.0:14268->14268/tcp, 0.0.0.0:6831-6832->6831-6832/udp, 0.0.0.0:16686->16686/tcp, 14250/tcp jaeger

Inventory

  • Clone inventory repository
git clone https://github.com/ibm-garage-ref-storefront/inventory-ms-openliberty
cd inventory-ms-openliberty

Deploy MySQL database


# Start a MySQL Container with a database user, a password, and create a new database
docker run --name inventorymysql \
-e MYSQL_ROOT_PASSWORD=admin123 \
-e MYSQL_USER=dbuser \
-e MYSQL_PASSWORD=password \
-e MYSQL_DATABASE=inventorydb \
-p 3306:3306 \
-d mysql:5.7.14

If it is successfully deployed, you will see something like below.

$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
6156756ba27c mysql:5.7.14 "docker-entrypoint.s…" 5 seconds ago Up 3 seconds 0.0.0.0:3306->3306/tcp inventorymysql
  • Now let us populate the MySQL with data.

Firstly, ssh into the MySQL container.

docker exec -it inventorymysql bash
  • Now, run the below command for table creation.
mysql -udbuser -ppassword
  • This will take you to something like below.
root@d88a6e5973de:/# mysql -udbuser -ppassword
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.14 MySQL Community Server (GPL)
Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
  • Go to scripts > mysql_data.sql. Copy the contents from mysql_data.sql and paste the contents in the console.

  • You can exit from the console using exit.

mysql> exit
Bye
  • To come out of the container, enter exit.
root@d88a6e5973de:/# exit

Deploy Inventory app


Run the below command.

# Build inventory docker image
appsody build
# Start the Inventory Container
docker run --name inventory-ms-openliberty \
-e jdbcURL=jdbc:mysql://host.docker.internal:3306/inventorydb?useSSL=true \
-e dbuser=dbuser \
-e dbpassword=password \
-e JAEGER_SERVICE_NAME=inventory-ms-openliberty \
  • You can also verify it as follows.
$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
c83fb01c87f9 dev.local/inventory-ms-openliberty "/opt/ol/helpers/run…" About an hour ago Up About an hour 9443/tcp, 0.0.0.0:9081->9080/tcp inventory-ms-openliberty
df370368c115 jaegertracing/all-in-one:1.11 "/go/bin/all-in-one-…" About an hour ago Up About an hour 0.0.0.0:5775->5775/udp, 0.0.0.0:5778->5778/tcp, 0.0.0.0:9411->9411/tcp, 0.0.0.0:14268->14268/tcp, 0.0.0.0:6831-6832->6831-6832/udp, 0.0.0.0:16686->16686/tcp, 14250/tcp jaeger
6156756ba27c mysql:5.7.14 "docker-entrypoint.s…" About an hour ago Up About an hour 0.0.0.0:3306->3306/tcp inventorymysql
  • Exit out of repo.
cd ..

Catalog

  • Clone catalog repository
git clone https://github.com/ibm-garage-ref-storefront/catalog-ms-spring.git
cd catalog-ms-spring

Deploy ElasticSearch


# Start an Elasticsearch Container
docker run --name catalogelasticsearch \
-e "discovery.type=single-node" \
-p 9200:9200 \
-p 9300:9300 \
-d docker.elastic.co/elasticsearch/elasticsearch:6.3.2

If it is successfully deployed, you will see something like below.

$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
07fb73eba00b docker.elastic.co/elasticsearch/elasticsearch:6.3.2 "/usr/local/bin/dock…" 25 seconds ago Up 20 seconds 0.0.0.0:9200->9200/tcp, 0.0.0.0:9300->9300/tcp catalogelasticsearch
c83fb01c87f9 dev.local/inventory-ms-openliberty "/opt/ol/helpers/run…" About an hour ago Up About an hour 9443/tcp, 0.0.0.0:9081->9080/tcp inventory-ms-openliberty
df370368c115 jaegertracing/all-in-one:1.11 "/go/bin/all-in-one-…" About an hour ago Up About an hour 0.0.0.0:5775->5775/udp, 0.0.0.0:5778->5778/tcp, 0.0.0.0:9411->9411/tcp, 0.0.0.0:14268->14268/tcp, 0.0.0.0:6831-6832->6831-6832/udp, 0.0.0.0:16686->16686/tcp, 14250/tcp jaeger
6156756ba27c mysql:5.7.14 "docker-entrypoint.s…" About an hour ago Up About an hour 0.0.0.0:3306->3306/tcp inventorymysql

Deploy Catalog app


Run the below command.

# Build catalog docker image
appsody build
# Start the Catalog Container
docker run --name catalog-ms-openliberty \
-e elasticsearch_url=http://host.docker.internal:9200 \
-e elasticsearch_index=micro \
-e elasticsearch_doc_type=items \
-e dev.appsody.application.client.InventoryServiceClient/mp-rest/url=http://host.docker.internal:9081/micro/inventory \
  • You can also verify it as follows.
$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
3d000493ff61 dev.local/catalog-ms-openliberty "/opt/ol/helpers/run…" 9 seconds ago Up 8 seconds 9443/tcp, 0.0.0.0:9082->9080/tcp catalog-ms-openliberty
07fb73eba00b docker.elastic.co/elasticsearch/elasticsearch:6.3.2 "/usr/local/bin/dock…" 31 minutes ago Up 31 minutes 0.0.0.0:9200->9200/tcp, 0.0.0.0:9300->9300/tcp catalogelasticsearch
c83fb01c87f9 dev.local/inventory-ms-openliberty "/opt/ol/helpers/run…" 2 hours ago Up 2 hours 9443/tcp, 0.0.0.0:9081->9080/tcp inventory-ms-openliberty
df370368c115 jaegertracing/all-in-one:1.11 "/go/bin/all-in-one-…" 2 hours ago Up 2 hours 0.0.0.0:5775->5775/udp, 0.0.0.0:5778->5778/tcp, 0.0.0.0:9411->9411/tcp, 0.0.0.0:14268->14268/tcp, 0.0.0.0:6831-6832->6831-6832/udp, 0.0.0.0:16686->16686/tcp, 14250/tcp jaeger
6156756ba27c mysql:5.7.14 "docker-entrypoint.s…" 2 hours ago Up 2 hours 0.0.0.0:3306->3306/tcp inventorymysql
  • Exit out of repo.
cd ..

Set Up Keystore

  • Clone the below repositories
git clone https://github.com/ibm-garage-ref-storefront/auth-ms-openliberty.git
git clone https://github.com/ibm-garage-ref-storefront/customer-ms-openliberty.git
git clone https://github.com/ibm-garage-ref-storefront/orders-ms-openliberty.git
  • Clone storefront automator
git clone https://github.com/ibm-garage-ref-storefront/storefront-repo-automator.git
cd storefront-repo-automator
  • Run the below script to create necessary key store files in auth-ms-openliberty, customer-ms-openliberty, and orders-ms-openliberty
./keystore.sh

If successfully created, you will see something like below.

$ ./keystore.sh
Keystore type: PKCS12
Keystore provider: SUN
Your keystore contains 1 entry
bckey, Nov 26, 2020, PrivateKeyEntry,
Certificate fingerprint (SHA1): C8:60:C0:4B:8D:46:70:10:AE:6E:82:9B:61:67:C0:BD:68:42:D9:0F
Certificate stored in file <client.cer>
  • Exit out of repo.
cd ..

Auth

  • Go to auth repository
cd auth-ms-openliberty

Deploy Auth app


Run the below command.

# Build auth docker image
appsody build
# Start the Auth Container
docker run --name auth-ms-openliberty \
-p 9083:9080 \
-p 9444:9443 \
-e jwksIssuer="https://localhost:9444/oidc/endpoint/OP" \
-d dev.local/auth-ms-openliberty
  • You can also verify it as follows.
$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
f27f340d270f dev.local/auth-ms-openliberty "/opt/ol/helpers/run…" 8 seconds ago Up 7 seconds 0.0.0.0:9083->9080/tcp, 0.0.0.0:9444->9443/tcp auth-ms-openliberty
3d000493ff61 dev.local/catalog-ms-openliberty "/opt/ol/helpers/run…" 12 minutes ago Up 12 minutes 9443/tcp, 0.0.0.0:9082->9080/tcp catalog-ms-openliberty
07fb73eba00b docker.elastic.co/elasticsearch/elasticsearch:6.3.2 "/usr/local/bin/dock…" 43 minutes ago Up 43 minutes 0.0.0.0:9200->9200/tcp, 0.0.0.0:9300->9300/tcp catalogelasticsearch
c83fb01c87f9 dev.local/inventory-ms-openliberty "/opt/ol/helpers/run…" 2 hours ago Up 2 hours 9443/tcp, 0.0.0.0:9081->9080/tcp inventory-ms-openliberty
df370368c115 jaegertracing/all-in-one:1.11 "/go/bin/all-in-one-…" 2 hours ago Up 2 hours 0.0.0.0:5775->5775/udp, 0.0.0.0:5778->5778/tcp, 0.0.0.0:9411->9411/tcp, 0.0.0.0:14268->14268/tcp, 0.0.0.0:6831-6832->6831-6832/udp, 0.0.0.0:16686->16686/tcp, 14250/tcp jaeger
6156756ba27c mysql:5.7.14 "docker-entrypoint.s…" 2 hours ago Up 2 hours 0.0.0.0:3306->3306/tcp inventorymysql
  • Exit out of repo.
cd ..

Customer

  • Go to customer repository
cd customer-ms-openliberty

Deploy CouchDB


# Start a CouchDB Container with a database user, a password, and create a new database
docker run -d -e COUCHDB_USER='admin' -e COUCHDB_PASSWORD='password' -p 5984:5984 couchdb

If it is successfully deployed, you will see something like below.

$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
d0f2e4491ec9 couchdb "tini -- /docker-ent…" 7 seconds ago Up 6 seconds 4369/tcp, 9100/tcp, 0.0.0.0:5984->5984/tcp beautiful_goldberg
f27f340d270f dev.local/auth-ms-openliberty "/opt/ol/helpers/run…" 2 minutes ago Up 2 minutes 0.0.0.0:9083->9080/tcp, 0.0.0.0:9444->9443/tcp auth-ms-openliberty
3d000493ff61 dev.local/catalog-ms-openliberty "/opt/ol/helpers/run…" 14 minutes ago Up 14 minutes 9443/tcp, 0.0.0.0:9082->9080/tcp catalog-ms-openliberty
07fb73eba00b docker.elastic.co/elasticsearch/elasticsearch:6.3.2 "/usr/local/bin/dock…" 45 minutes ago Up 45 minutes 0.0.0.0:9200->9200/tcp, 0.0.0.0:9300->9300/tcp catalogelasticsearch
c83fb01c87f9 dev.local/inventory-ms-openliberty "/opt/ol/helpers/run…" 2 hours ago Up 2 hours 9443/tcp, 0.0.0.0:9081->9080/tcp inventory-ms-openliberty
df370368c115 jaegertracing/all-in-one:1.11 "/go/bin/all-in-one-…" 2 hours ago Up 2 hours 0.0.0.0:5775->5775/udp, 0.0.0.0:5778->5778/tcp, 0.0.0.0:9411->9411/tcp, 0.0.0.0:14268->14268/tcp, 0.0.0.0:6831-6832->6831-6832/udp, 0.0.0.0:16686->16686/tcp, 14250/tcp jaeger
6156756ba27c mysql:5.7.14 "docker-entrypoint.s…" 2 hours ago Up 2 hours 0.0.0.0:3306->3306/tcp inventorymysql
  • Populate the database with user information.
cd populate
python3 populate.py localhost 5984
cd ..

Deploy Customer app


Run the below command.

# Build customer docker image
appsody build
# Start the customer Container
docker run --name customer-ms-openliberty \
-e jwksIssuer="https://localhost:9444/oidc/endpoint/OP" \
-e keystorePassword="password" \
-e dev.appsody.customer.client.CouchDBClientService/mp-rest/url="http://host.docker.internal:5984" \
-e couchuser=admin \
  • You can also verify it as follows.
$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
3a6cd3a178ee dev.local/customer-ms-openliberty "/opt/ol/helpers/run…" 5 seconds ago Up 3 seconds 0.0.0.0:9085->9080/tcp, 0.0.0.0:9446->9443/tcp customer-ms-openliberty
d0f2e4491ec9 couchdb "tini -- /docker-ent…" 3 minutes ago Up 3 minutes 4369/tcp, 9100/tcp, 0.0.0.0:5984->5984/tcp beautiful_goldberg
f27f340d270f dev.local/auth-ms-openliberty "/opt/ol/helpers/run…" 5 minutes ago Up 5 minutes 0.0.0.0:9083->9080/tcp, 0.0.0.0:9444->9443/tcp auth-ms-openliberty
3d000493ff61 dev.local/catalog-ms-openliberty "/opt/ol/helpers/run…" 17 minutes ago Up 17 minutes 9443/tcp, 0.0.0.0:9082->9080/tcp catalog-ms-openliberty
07fb73eba00b docker.elastic.co/elasticsearch/elasticsearch:6.3.2 "/usr/local/bin/dock…" 48 minutes ago Up 48 minutes 0.0.0.0:9200->9200/tcp, 0.0.0.0:9300->9300/tcp catalogelasticsearch
c83fb01c87f9 dev.local/inventory-ms-openliberty "/opt/ol/helpers/run…" 2 hours ago Up 2 hours 9443/tcp, 0.0.0.0:9081->9080/tcp inventory-ms-openliberty
df370368c115 jaegertracing/all-in-one:1.11 "/go/bin/all-in-one-…" 2 hours ago Up 2 hours 0.0.0.0:5775->5775/udp, 0.0.0.0:5778->5778/tcp, 0.0.0.0:9411->9411/tcp, 0.0.0.0:14268->14268/tcp, 0.0.0.0:6831-6832->6831-6832/udp, 0.0.0.0:16686->16686/tcp, 14250/tcp jaeger
  • Exit out of repo.
cd ..

Orders

  • Go to orders repository
cd orders-ms-openliberty

Deploy Mariadb


# Start a MariaDB Container with a database user, a password, and create a new database
docker run --name ordersmysql \
-e MYSQL_ROOT_PASSWORD=admin123 \
-e MYSQL_USER=dbuser \
-e MYSQL_PASSWORD=password \
-e MYSQL_DATABASE=ordersdb \
-p 3307:3306 \
-d mariadb

If it is successfully deployed, you will see something like below.

$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
12bfad474f24 mariadb "docker-entrypoint.s…" 48 seconds ago Up 45 seconds 0.0.0.0:3307->3306/tcp ordersmysql
3a6cd3a178ee dev.local/customer-ms-openliberty "/opt/ol/helpers/run…" 3 minutes ago Up 3 minutes 0.0.0.0:9085->9080/tcp, 0.0.0.0:9446->9443/tcp customer-ms-openliberty
d0f2e4491ec9 couchdb "tini -- /docker-ent…" 6 minutes ago Up 6 minutes 4369/tcp, 9100/tcp, 0.0.0.0:5984->5984/tcp beautiful_goldberg
f27f340d270f dev.local/auth-ms-openliberty "/opt/ol/helpers/run…" 8 minutes ago Up 8 minutes 0.0.0.0:9083->9080/tcp, 0.0.0.0:9444->9443/tcp auth-ms-openliberty
3d000493ff61 dev.local/catalog-ms-openliberty "/opt/ol/helpers/run…" 21 minutes ago Up 20 minutes 9443/tcp, 0.0.0.0:9082->9080/tcp catalog-ms-openliberty
07fb73eba00b docker.elastic.co/elasticsearch/elasticsearch:6.3.2 "/usr/local/bin/dock…" 51 minutes ago Up 51 minutes 0.0.0.0:9200->9200/tcp, 0.0.0.0:9300->9300/tcp catalogelasticsearch
c83fb01c87f9 dev.local/inventory-ms-openliberty "/opt/ol/helpers/run…" 2 hours ago Up 2 hours 9443/tcp, 0.0.0.0:9081->9080/tcp inventory-ms-openliberty
  • Create the orders table.

Firstly ssh into the MySQL container.

docker exec -it ordersmysql bash
  • Now, run the below command for table creation.
mysql -udbuser -ppassword
  • This will take you to something like below.
root@5762edb59a86:/# mysql -udbuser -ppassword
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 22
Server version: 10.5.5-MariaDB-1:10.5.5+maria~focal mariadb.org binary distribution
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
  • Go to scripts > mysql_data.sql. Copy the contents from mysql_data.sql and paste the contents in the console.

  • You can exit from the console using exit.

MariaDB [(none)]> exit
Bye
  • To come out of the container, enter exit.
root@5762edb59a86:/# exit
exit

Deploy Orders app


Run the below command.

# Build orders docker image
appsody build
# Start the Orders Container
docker run --name orders-ms-openliberty \
-e jdbcURL=jdbc:mysql://host.docker.internal:3307/ordersdb?useSSL=true \
-e dbuser=dbuser \
-e dbpassword=password \
-e jwksIssuer="https://localhost:9444/oidc/endpoint/OP" \
  • You can also verify it as follows.
$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
c6ca0064e496 dev.local/orders-ms-openliberty "/opt/ol/helpers/run…" 8 seconds ago Up 6 seconds 0.0.0.0:9084->9080/tcp, 0.0.0.0:9445->9443/tcp orders-ms-openliberty
12bfad474f24 mariadb "docker-entrypoint.s…" 5 hours ago Up 5 hours 0.0.0.0:3307->3306/tcp ordersmysql
3a6cd3a178ee dev.local/customer-ms-openliberty "/opt/ol/helpers/run…" 5 hours ago Up 5 hours 0.0.0.0:9085->9080/tcp, 0.0.0.0:9446->9443/tcp customer-ms-openliberty
d0f2e4491ec9 couchdb "tini -- /docker-ent…" 5 hours ago Up 5 hours 4369/tcp, 9100/tcp, 0.0.0.0:5984->5984/tcp beautiful_goldberg
f27f340d270f dev.local/auth-ms-openliberty "/opt/ol/helpers/run…" 5 hours ago Up 5 hours 0.0.0.0:9083->9080/tcp, 0.0.0.0:9444->9443/tcp auth-ms-openliberty
3d000493ff61 dev.local/catalog-ms-openliberty "/opt/ol/helpers/run…" 5 hours ago Up 5 hours 9443/tcp, 0.0.0.0:9082->9080/tcp catalog-ms-openliberty
07fb73eba00b docker.elastic.co/elasticsearch/elasticsearch:6.3.2 "/usr/local/bin/dock…" 5 hours ago Up 5 hours 0.0.0.0:9200->9200/tcp, 0.0.0.0:9300->9300/tcp catalogelasticsearch
  • Exit out of repo.
cd ..

Storefront UI

  • Clone Storefront-UI repository
git clone https://github.com/ibm-garage-ref-storefront/storefront-ui.git
cd storefront-ui

Deploy Storefront UI


Run the below command.

# Build storefront ui docker image
appsody build
# Start the Storefront UI Container
docker run --name web \
-e NODE_ENV=development \
-p 3000:3000 \
-d dev.local/web
  • You can also verify it as follows.
$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
60d37579ce50 dev.local/web "container-entrypoin…" 11 seconds ago Up 9 seconds 0.0.0.0:3000->3000/tcp, 8080/tcp web
c6ca0064e496 dev.local/orders-ms-openliberty "/opt/ol/helpers/run…" 14 minutes ago Up 14 minutes 0.0.0.0:9084->9080/tcp, 0.0.0.0:9445->9443/tcp orders-ms-openliberty
12bfad474f24 mariadb "docker-entrypoint.s…" 5 hours ago Up 5 hours 0.0.0.0:3307->3306/tcp ordersmysql
3a6cd3a178ee dev.local/customer-ms-openliberty "/opt/ol/helpers/run…" 5 hours ago Up 5 hours 0.0.0.0:9085->9080/tcp, 0.0.0.0:9446->9443/tcp customer-ms-openliberty
d0f2e4491ec9 couchdb "tini -- /docker-ent…" 5 hours ago Up 5 hours 4369/tcp, 9100/tcp, 0.0.0.0:5984->5984/tcp beautiful_goldberg
f27f340d270f dev.local/auth-ms-openliberty "/opt/ol/helpers/run…" 5 hours ago Up 5 hours 0.0.0.0:9083->9080/tcp, 0.0.0.0:9444->9443/tcp auth-ms-openliberty
3d000493ff61 dev.local/catalog-ms-openliberty "/opt/ol/helpers/run…" 5 hours ago Up 5 hours 9443/tcp, 0.0.0.0:9082->9080/tcp catalog-ms-openliberty

There you go, you deploy all the necessary services for storefront.

Now, let us check the app out. You can access it at http://localhost:3000.

Storefront