This project involves the containerization and deployment of a full-stack YOLO e-commerce application using Docker. The application consists of three services:
- A frontend (built with React and served using NGINX)
- A backend (Node.js API)
- A MongoDB database
Docker is used to build and manage these services, while Docker Compose orchestrates and networks them together in a multi-container environment.
Ensure you have the following installed:
- Vagrant - for setting up and managing virtualized development environments
- Ansible - for configuring the VM and provisioning services
- Docker - for containerization
This option is ideal if you have Docker installed locally and don’t need a virtual machine.
- Clone the Repository:
git clone [email protected]:ChepkemoiPeris/yolo.git cd yolo
- Start the Application:
docker compose up
This command will:
Pull the images for the frontend and backend from the repository. Set up networking between the services. Persist data in MongoDB using Docker volumes.
-
Access the Application:
- The frontend will be accessible at: http://localhost:80
- The backend will be running at: http://localhost:5000
-
Shutting Down the Application:
docker compose down
This option is ideal if you want to automate the provisioning of a virtual environment for Docker using Vagrant and Ansible.
- Clone the Repository:
git clone [email protected]:ChepkemoiPeris/yolo.git cd yolo
- Start Vagrant to Provision the Environment:
vagrant up --provision
This command will:
create a virtual machine and configure Docker (including setting up network and volume), mongo, and other dependencies using Ansible.
-
Access the Application:
- The frontend will be accessible at: http://localhost:8080
- The backend will be running at: http://localhost:5000
-
Shutting Down the Application: To completely remove the Vagrant environment:
vagrant destroy
- View Running Containers:
docker ps
- View Container Logs:
docker logs <container_name>
If you want to run the application on Kubernetes for scalability and production-like environments, you can use this option. You can test using minikube locally or deploy to cloud. Kubernetes manifest files are found on k8s/ folder.
- Clone the Repository:
git clone [email protected]:ChepkemoiPeris/yolo.git
- Navigate to Kubernetes YAML Files: Go to the k8s folder, where your Kubernetes deployment files are stored:
cd yolo/k8s
- Apply the Kubernetes Configurations: Use kubectl to apply the configurations. This will create services, config maps, and deployments as defined in the .yaml files:
kubectl apply -f .
This will:
- Create the necessary deployments for the frontend and backend.
- Create the statefulset for the MongoDB.
- Create services to expose the frontend and backend.
- Create backend and frontend config maps for configuration management.
- Get the External IP:
kubectl get svc frontend-service
This will display the external IP assigned to the frontend. It might take a few moments for the LoadBalancer to be provisioned. You will not get this if you are using minikube, you can skip this step.
- Access the Application:
Once you have the external IP, you can access the application in your browser:
- If you are using minikube you can access application using:
minikube service frontend-service
- If you are on live server you can use:
http://<external-ip>:80
You can access the live version of this application at: http://34.30.39.228/
This link points to the production deployment of the application, it was deployed on Google Kubernetes Engine(GKE) cluster using GCP.