This project involves building and deploying a three-tier application(todo list application from Docker) to a Minikube cluster, simulating a real-world multi-environment setup.
The goal of this README is to explain the steps to replicate this project, particularly for those who might have little to no knowledge of the subject. I’ll provide tutorials and guides along the way.
Before we jump into the project, make sure you have the following installed on your machine:
- Docker: You can get started here: Get Docker Desktop.
- Minikube: Install it from this guide: Minikube Start.
- Docker Hub Account: Sign up here: Docker Hub.
For this step, we’ll use a three-tier app (frontend, backend, and database) provided by Docker. Check out the official Docker documentation for a quick start: Develop with Containers. The Dockerfile is already written to containerize the app.
- React Frontend: A Node container running the React development server, using Vite.
- Node Backend: Provides an API to retrieve, create, and delete to-do items.
- MySQL Database: Stores the list of items.
- phpMyAdmin: A web-based interface to interact with the database, accessible at http://db.localhost.
- Traefik Proxy: Routes requests appropriately, sending requests for
localhost/api/*
to the backend, requests forlocalhost/*
to the frontend, and requests fordb.localhost
to phpMyAdmin, allowing access through port 80.
Use the following command to clone/download the files:
git clone https://github.com/docker/getting-started-todo-app
To ensure all services connect, run:
docker compose watch
(Psst! You need to be in the same folder to run docker-compose
. If you are not, use this command before running Docker Compose: cd getting-started-todo-app
).
Once you execute the above command, you should see the status:
Now, we will build our image and push it to Docker Hub.
-
Create a New Repository: First, go to your Docker Hub account and create a new repository.
-
Build the Image: Use the following command:
docker build -t <DOCKER_USERNAME>/todoapp .
-
Check Your Image: Run the following command to confirm everything went smoothly:
docker image ls
-
Push it to Docker Hub: Once confirmed, push it to Docker Hub using:
docker push <DOCKER_USERNAME>/getting-started-todo-app
You have successfully built and pushed your image to Docker Hub.
Now that we’re set with our image, it’s time to deploy our app to Kubernetes. For the local section of this guide, we’ll be using Minikube. If you haven’t installed Minikube yet, follow this guide: Minikube Start.
Stay tuned for more details on the deployment process!