Why you should be using Docker containers for your React/Angular apps
Matthew Parton
Helping Companies Build Stunning Web Apps with Free UX/UI Design + Development & Hosting
Have you used docker yet to build your applications? I would highly recommend that you take the time to use it. It really is an excellent product and will streamline your development pipeline.
Working with my own company Insignia Health since 2011 we have been developing applications for a long time for various companies of different sizes, using various flavours of front end tools in that time. ASP, ASP.NET MVC, angularjs, knockout, javascript, reactjs etc. One of the biggest challenges for any developer is having a local development environment that emulates the production environment as close a possible.
This helps development for many reasons
?
Many companies today that I have worked with still deploy applications onto servers that are uniquely different to the ones they operate in production. For example, a recent client of ours worked with IIS on there main production servers and used IIS express as a local environment. The difference in the two environments was vast. The settings and configuration are so different that when bugs occur, you cannot simply eliminate the possibilities of environment changes causing the issues. This can be program installations on the local vs production machines, same software but different versions, configuration differences and so much more.
Instead you can spend hours or days trying to get an environment locally that emulates the production one. This brings massive costs to the development teams and the business as a whole.
You can reduce this impact though, using Docker as a local development and testing environment.
Here at Insignia Health we deploy our applications using a standard approach.
We use standard git flow process to automate and control deployment from development into testing and production pipelines. I have left those process details out here for brevity.
?
Advantages that docker brings!
Docker brings a massive advantage to the table that other deployments do not:
There are some obvious environment differences in production to development and testing ones, however as these are much smaller, the ability to track things down is much easier for the teams, and its easier to do in isolation without impacting live server (in most cases).
?
Example Docker File
This is an example docker file we have used in one of our projects. To newbies it may look a little complicated, but in the main, it really is boiler plate code. Although a little cumbersome you can get a container up and running in less that a few hours.
领英推荐
This file takes the local created react application and builds it in a two stage process using npm build scripts. The output of the first is used and added to the second layer. All temporary files are removed as a result, keeping the outputs for the server much smaller in the final container.
We use nginx for our main server deployment, this allows a better isolation of our infrastructure from the outside world and we can configure https tunnels to terminate there.
?
Conclusion
Although this is not a detailed article about using docker itself, I wanted to give an overview of why we use it and the advantages it brings to development teams. You should seriously consider using docker, if you are not already doing so as it really does improve the development life cycle.
?
References
?
About Me
I am Matthew Parton, I am a Front end web specialist working with React/Angular, I have been developing web applications for well over 30 years and all its the flavours. I now build cloud enabled front end applications for web and mobile, fully deployed into Kubernetes environments running on linux based docker containers in AWS or Azure.
If you want some help with your application or your teams then feel free to contact me using [email protected] or calling me directly on 07854131382.