Orchestrate Our React Application in Docker

Fran Na Jaya
Basic People
Published in
3 min readApr 30, 2019

Need to manage many docker containers? Need to communicate two or more containers? Orchestration is the solution

Docker is one of many tools to develop application. Docker use image as the base application source to serve on a container and service. So, when you use docker as your service you need to make any of your application appear as image docker. There are already exist so many base image serve by Docker as Node, nginx, Django, postgre, and else.

When you develop applications sometimes you meet so many image in one Software, you know it right? As example you want to make your application front end based on React, and you want to make your database use postgre, then at least you need two containers for the front end and the back end. Then you have to think how to connect them, you can use services to connect it.

Two image to serve one applications, it will be exhausting you to manage it one by one and deploy it one by one. Here is orchestration Docker show up to solve the problem. So, what are Container Orchestration manage?

Container orchestration usually used to manage and automate many task, including :

  • Provisioning and deployment of containers
  • Redundancy and availability of containers
  • Scaling up or removing containers to spread application load evenly across host infrastructure
  • Movement of containers from one host to another if there is a shortage of resources in a host, or if a host dies
  • Allocation of resources between containers
  • External exposure of services running in a container with the outside world
  • Load balancing of service discovery between containers
  • Health monitoring of containers and hosts
  • Configuration of an application in relation to the containers running it

Docker Orchestration examples that usually used is:

  1. Kubernetes
  2. Swarm
  3. Apache Meos

So how to make the docker orchestrations? In simple way you can use yml configuration through docker-compose.yml

Explanations about the docker-compose above:

Using version 3.4 of the compose service. The composer define to make service of web. In web they have build and environments.

Docker orchestration in our team

So, basically we don’t need the orchestration up until now because we only create a front-end application and not creating database system for our applications. As the result we only manage Dockerfile to serve our applications.

Here is the brief explanation of this

Software Architecture

First of all, our application is doing a revamp in admin site Lapor.go because of that we don’t have any database in our apps. So, we doesn’t need an orchestration because we only develop the front end.

We also change the dockerfiles functionalities, in the begining of this development we use nginx to develop our app. After searching about nginx layer for nodejs we know that nginx is used for load balancing the react application serving.

Our application doesn’t use any database, we subtitute the database system use json files. So there is no need to use load balancer for our application. Then, we create new dockerfiles that fulfill our needed.

This is our new docekerfiles.

This dockerfile use node base image.

Then copy all the files and folder in directory to the image.

Then expose port 80 for development

The last syntax is CMD. This task run the npm run startstaging to run the development

Conclusion

So, we don’t use the orchestration and load balancer in our software architecture because we don’t use any database.

--

--

Fran Na Jaya
Basic People

Hi all, introducing a person who will live long enough to know he were right on each of his decisions. Currently works as Software Engineer at Ajaib