https://github.com/iambotcoder/vprofile-docker
The "VProfile Project - Docker Compose Setup" automates the deployment and orchestration of essential services, including database, caching, messaging, and web application components, using Docker Compose.
https://github.com/iambotcoder/vprofile-docker
automation containerization devops docker docker-compose vprofile
Last synced: about 2 months ago
JSON representation
The "VProfile Project - Docker Compose Setup" automates the deployment and orchestration of essential services, including database, caching, messaging, and web application components, using Docker Compose.
- Host: GitHub
- URL: https://github.com/iambotcoder/vprofile-docker
- Owner: iambotcoder
- Created: 2025-02-17T16:25:11.000Z (about 1 year ago)
- Default Branch: master
- Last Pushed: 2025-02-17T16:46:14.000Z (about 1 year ago)
- Last Synced: 2025-02-17T17:32:52.814Z (about 1 year ago)
- Topics: automation, containerization, devops, docker, docker-compose, vprofile
- Homepage:
- Size: 25.4 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# π VProfile Project - Docker Compose Setup
---
## π Overview
This document provides a step-by-step guide to setting up a **Vagrant Virtual Machine** using **Ubuntu Jammy**. The setup includes networking, resource allocation, and provisioning options to automate the development environment.
---
## π Table of Contents
- [Prerequisites](#-prerequisites) π
- [Architecture](#-architecture) πΊοΈ
- [Setup & Installation](#-setup-and-installation) π οΈ
- [Vagrant Setup](#-vagrant-setup) πΎ
- [Docker Setup](#-docker-setup) π³
- [Cleaning Up Resources](#-cleaning-up-resources) π§Ή
- [Conclusion](#-conclusion) β
---
## π Prerequisites
Before starting, ensure you have the following installed:
- [Vagrant](https://www.vagrantup.com/downloads)
- [VirtualBox](https://www.virtualbox.org/wiki/Downloads)
- A terminal or command prompt with administrative privileges
---
## πΊοΈ Architecture
This project utilizes Vagrant to set up an **Ubuntu virtual machine** with the following configurations:
- **Base OS:** Ubuntu Jammy 64-bit
- **Networking:**
- Private network with a static IP (`192.168.56.14`)
- Public network for external access
- **Resource Allocation:**
- Memory: 1600MB
- CPUs: 2
- **Synced Folder:**
- Maps `D:\scripts\shellscripts` on the host to `/opt/scripts` in the VM
- **Provisioning (Optional):**
- Can be configured to install packages (like Apache) automatically
### Workflow:
1. **Initialize Vagrant** β Create the required configuration.
2. **Start the VM** β Boot the virtual machine.
3. **Access the VM** β SSH into the machine.
4. **Validate Network Settings** β Check assigned IPs.
5. **Destroy the VM** β Cleanup once testing is complete.
---
## π οΈ Setup & Installation
### 1β£ Initialize Vagrant:
```bash
vagrant init
```
---
## πΎ Vagrant Setup π₯οΈ
Below is the `Vagrantfile` configuration used for this project:
```ruby
Vagrant.configure("2") do |config|
# Use Ubuntu Jammy 64-bit box
config.vm.box = "ubuntu/jammy64"
# Configure private network with specific IP
config.vm.network "private_network", ip: "192.168.56.82"
# Configure public network (Bridged network)
config.vm.network "public_network"
# VirtualBox specific configuration
config.vm.provider "virtualbox" do |vb|
vb.memory = "2048"
end
# Keep the default insecure SSH key
config.ssh.insert_key = false
# Provisioning with shell script to install Docker and Docker Compose
config.vm.provision "shell", inline: <<-SHELL
sudo apt-get update
sudo apt-get install ca-certificates curl gnupg -y
sudo install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
sudo chmod a+r /etc/apt/keyrings/docker.gpg
echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin -y
sudo curl -L "https://github.com/docker/compose/releases/download/v2.1.1/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose
SHELL
end
```
### 2β£ Start the Virtual Machine:
```bash
vagrant up
```
### 3β£ Check VM Status:
```bash
vagrant status
```
### 4β£ SSH into the VM:
```bash
vagrant ssh
```
### 5β£ Check Network Configuration:
```bash
ip addr show
```
### 6β£ Exit the VM:
```bash
exit
```
---
## π³ Docker Setup
### 1β£ **Install Docker inside the VM**:
```bash
sudo apt-get update
sudo apt-get install -y docker.io
```
### 2β£ **Verify Docker Installation**:
```bash
docker --version
```
### 3β£ **Run a Test Container**:
```bash
docker run hello-world
```
### 4β£ **Docker Compose Setup**:
Install Docker Compose inside the VM if it's not already installed:
```bash
sudo apt-get install -y docker-compose
```
### 5β£ **Create a `docker-compose.yml` File**:
In your VM, create a `docker-compose.yml` file with the following content:
```yaml
version: '3.8'
services:
vprodb:
image: vprofile/vprofiledb
ports:
- "3306:3306"
volumes:
- vprodbdata:/var/lib/mysql
environment:
- MYSQL_ROOT_PASSWORD=vprodbpass
vprocache01:
image: memcached
ports:
- "11211:11211"
vpromq01:
image: rabbitmq
ports:
- "15672:15672"
environment:
- RABBITMQ_DEFAULT_USER=guest
- RABBITMQ_DEFAULT_PASS=guest
vproapp:
image: vprofile/vprofileapp
ports:
- "8080:8080"
volumes:
- vproappdata:/usr/local/tomcat/webapps
vproweb:
image: vprofile/vprofileweb
ports:
- "80:80"
volumes:
vprodbdata: {}
vproappdata: {}
```
### 6β£ **Start Docker Compose Services**:
Navigate to the directory where the `docker-compose.yml` file is located, then run:
```bash
docker-compose up -d
```
### 7β£ **Verify Running Containers**:
```bash
docker-compose ps
```
### 8β£ **Stop Docker Compose Services**:
```bash
docker-compose down
```
---
## π§Ή Cleaning Up Resources
To remove the VM and free up system resources, run the following commands in order:
### 1β£ Destroy the Virtual Machine:
```bash
vagrant destroy
```
### 2β£ Remove Unused Vagrant Instances:
```bash
vagrant global-status --prune
```
---
## β
Conclusion
This project demonstrates how to automate VM provisioning using **Vagrant and VirtualBox**, making it easier to manage development and testing environments efficiently. It also integrates Docker to facilitate containerized application deployment within the VM.
---
## π¨βπ« Instructor
This project was guided by **Imran Teli**, who provided valuable mentorship throughout the process.
---