DEV Community

Arinze Nchor
Arinze Nchor

Posted on

Dockerizing a 3-tier application

Whewwww. Where do I start from? My very first post as a DevOps engineer documenting my progress and all, but here it goes.

This post only walks readers through the process of dockerizing a three-tier application for docker-hub. Usually, I am only experienced with dockerizing a single application, but I was able to accomplish this with the assistance of @hux_man on Twitter, who made a "DevOps-challenge" job for us engineers to work on real-time projects.

Developers that wish to dockerize their applications can use this project.

Prerequisites:

  • A Github Account
  • Docker Hub account
  • Node.js and npm installed on your local machine
  • Basic knowledge of Docker

The image below is the folder structure of my project. The frontend (React), Backend (NodeJs) and finally using a Postgres database.

Project structure

For the application, I had a Dockerfile in the frontend and backend directories. I'll use screenshots to show how my Dockerfiles work, along with the necessary comments for each line of code that describe what it does.

  • Frontend Dockerfile

My frontend dockerfile

  • Backend Dockerfile

My Backend dockerfile

  • My Docker-compose file

Docker-compose code

Utilizing a Docker-compose.yaml file allows you to define and execute several containers at once. With our understanding of Docker, it is easier to build and launch all applications at once rather than having to open each folder's unique Dockerfile, build, and push to Docker-Hub. Just typing the simple command "docker compose up" into your terminal will assist Docker-compose lessen this stress.

Containerized images on docker-hub

Here, I was able to quickly and efficiently deploy my three-tier application to Docker-hub with the help of Docker Compose.

Conclusion:

This project provides a foundation for deploying a 3-tier application to Docker-Hub.

Please feel free to express concerns, offer corrections where needed, and suggest ways to improve the Dockerizing of applications. To improve as a DevOps Engineer, I would be more than happy to learn more and pay attention to corrections.

Top comments (0)