Before we can run our facade, we need to add three more things: a factory for the component’s we’ve created, a container, and the code that will run it all. The process of implementing these pieces is the same as the one described in Data Microservice, so this time around we’ll just list the code:
Create three factories in the src/build/ folder:
One factory for the facade in a file named FacadeFactory.ts, containing the following code:
/src/build/FacadeFactory.ts
Another factory for the facade’s services, placed in a file named ServiceFacadeFactory.ts:
/src/build/ServiceFacadeFactory.ts
And last but not least, a factory for the clients that that facade depends on in a file named ClientsFacadeFactory.ts:
/src/build/ClientFacadeFactory.ts
The container that we want to run our facade in should be implemented in a file named FacadeProcess.ts and placed in the /container folder:
/src/container/FacadeProcess.ts
For us to be able to run the container, create a run.js file in the /bin folder with the following code:
/bin/run.js
Our facade will need to be configured before running, so create a config-distributed.yml file in the /config folder of the project with the following:
/config/config.yml
For demonstration purposes, we’ll be running our system in a distributed mode, with all of its components running in their own, individual containers. The configuration above is designed specifically for this type of distributed deployment.
The process of running a service in a Docker container is described in detail in the Dockerization tutorial
To run our system using Docker Compose, create a docker-compose.yml file with the following:
/docker/docker-compose.yml
Build and run the facade using the respective scripts (described in the Docker tutorial we mentioned above), which can be found in this example project’s repository.
To build the facade’s image and load the rest of the services’ images, run the “package” script using the command below:
Once the build process successfully finishes, run the entire system with all of its microservices in Docker Compose using the “run” script. This can be done with the following command:
When running the facade, you should see something like this in the console:
Now we’re ready to move on to manually testing our facade. In Step 8 - Manually testing the facade - we’ll show you how this can be done.