football-player-ui

First, build the frontend application, as described in Chapter 5, Eclipse MicroProfile and Transactions – Narayana LRA; then, create the Dockerfile for the football-player-ui, as follows:

FROM docker.io/httpd
ADD football-player-ui/dist/football-player-ui/* /usr/local/apache2/htdocs/

Now, within the same path of the Docker file, build the Docker image, as follows:

docker build -f football-player-ui.dockerfile -t foogaro/football-player-ui 

Check that the image is actually on your local Docker registry, issuing the following command:

docker images

If the image that was just built is listed (it should appear at the top of the list), run the container, as follows:

docker run -it --rm=true --name="football-player-ui" --net="football" -p 80:80 foogaro/football-player-ui

Upon opening your browser and pointing to the URL at http://172.18.0.4/, the following page should appear:

As you can see in the preceding screenshot depicting the football-player-ui application, the page is blank, with no data in the table.

That's because we also need to hook the frontend with the backend football-player-microservice. To achieve such integration, we need to modify the file src/app/footballPlayer/football-player.service.ts and update the private member, named apiUrl, with the following statement:

private apiUrl = 'http://172.18.0.3:8180/footballplayer';

The IP and port refer to the backing service. After rebuilding the frontend, rebuilding the Docker image foogaro/football-player-ui, and rerunning the container, the overall system should now work with no issues, as shown in the following screenshot:

As you must have figured out while reading this chapter, dealing with containers requires some extra work, and adds some complexity to your systems, but you will surely benefit from the automation, scalability, consistency, and integrity of the overall system.

Docker itself is very useful for developing and testing purposes, but in large environments, such as production, you need to orchestrate all of the containers yourself, and it can be very tedious and error-prone, which is something that you really do not want in a production environment.

Nowadays, there is software that provides container orchestration, such as Kubernetes.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset