November 31, 2022

Product Development with Docker

Photo by Rubaitul Azad on Unsplash

Deployment

You've built your three-tier application utilizing React.js for the frontend, Flask as a microservice, and node js with a MySQL database.

Projects of this scale will have a lot of moving parts and utilize many packages and libraries. These are the packages you install using "npm install" for javascript, or "pip3 install" for python.

These packages, or dependencies are often managed in files such as package.json, pom.xml, and requirements.txt, which store the versions of the dependencies that your project uses.

Whoever wants to use your project will have to download these dependencies for all programs to run.

There are two main challenges now. Firstly, it is often important to install dependencies in the correct order, as some dependencies may depend on others. If you just give a list of dependencies for someone to install, you can easily download a package first that is incompatible with another package you are downloading later.

For example, in the image the version of @material-core/ui I am trying to install is incompatible with the version of react that I am running is causing the application to crash.

Dependency Management

A much bigger challenge, however, is dealing with different versions of dependencies on different machines.

This is where Docker comes in. Docker allows you to streamline deploying applications which have a lot of services.

To solve this problem, Docker allows users to create a virtual machine, which is a simulated computer with a specific OS and software versions.

These containers are like mini computers which run on your own computer, but your computer allots some amount of ram, hard disk, and CPU to them.

To create these containers you must create a Dockerfile first. This dockerfile is essentially the commands which make the Docker Image.

Then you can run this image as a docker container.

When updating a program or the OS, a new image can be created. All your applications can run on all types of OS systems now whether its mac, linux, or windows.

Users can also add scripts to their image to customize it, such as changing MySQL admin and password settings.

Images have different versions in which you can pull the latest version, or an image before that. Can push and pull from docker repositories.

Run It!

  1. docker build -t [name] [can specify port]
  2. docker run [name]

Once the image is running, open a shell inside the container

  1. docker container ls
  2. docker exec -it [container id] bin/bash

Now you have the ability to connect to a MySQL server from the specified container that you are currently in. Now you can write any amount of SQL commands in the terminal and it will automatically connect to your database through the container.

  1. mysql -p[YOUR_PASSWORD]
  2. sql commands

What we have done is a prime example of dockerization. This is extremely useful because now this MySQL server can be configured on any machine in the entire world without any sort of issues. As long as you have docker installed on your machine, this script will also work. It's also easier to test between different versions if you have to bump some versions or compare in production.

Other Challenges

There are also other problems in large scale development, on which I'll briefly touch on here. Understanding large scale production is completely different than coding by yourself, alone. Large scale web development includes different types of roles, and also the tools that people in these roles leverage.

Product managers are responsible for gathering feedback from customers and working with engineers to develop a product. On the other hand, engineering managers collaborate with architects and designers to create prototypes and work with engineers to develop a product. Jira is a project management tool that helps teams track and prioritize work on a product. It includes features for organizing work into "epics" (overarching goals) and "stories" (individual tasks), as well as tracking "bugs" (problems with the code). Git and CI/CD (continuous integration/continuous delivery) tools help teams collaborate on code development and review code changes before they are merged into the main codebase.

Kubernetes is a software that allows users to easily scale their product up or down in response to changes in traffic. It relies on the principle of using containers to package applications and their dependencies, rather than using virtual machines. Containers are lightweight and can be run on different machines without requiring specific hardware configurations. This makes them more cost-effective than virtual machines. Kubernetes can help manage and restart containers, resolve version conflicts, and balance load across multiple containers running in the cloud using AWS (Amazon Web Services). Kind is a tool that allows users to run the Kubernetes software using Docker. The operating system (OS) allows users to interact with software on a computer.

Overall, there are several challenges for large scale web development, but with the right tools those are easily overcame, and you can easily deploy your multi-million dollar software.