This Employee Management System is a microservices-based application designed to manage employee data. It consists of two main components:
- Add Employee Service (add-emp-micro)
- Search Employee Service (search-emp-micro)
The system is containerized using Docker and orchestrated with Docker Compose, making it easy to deploy and manage.
- Amazon EC2 instance (Amazon Linux 2 or Ubuntu Server 20.04 LTS recommended)
- Docker and Docker Compose installed on the EC2 instance
- Git for cloning the repository
- EC2 security group configured to allow inbound traffic on ports 80 (HTTP), and 8080 (Custom TCP)
-
Install Docker and Docker Compose:
# For Amazon Linux 2 sudo yum update -y sudo amazon-linux-extras install docker sudo service docker start sudo usermod -a -G docker ec2-user sudo chkconfig docker on # For Ubuntu sudo apt update sudo apt install -y docker.io # Install Docker Compose sudo curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose sudo chmod +x /usr/local/bin/docker-compose
-
Log out and log back in to apply the docker group changes.
-
Clone the repository:
git clone https://github.com/shamimice03/docker-project.git cd docker-project
-
Deploy the
add-emp-micro
service:- Move to the directory
cd add-emp-micro
- Change
EC2_PUBLIC_URL=<ip or dns>
indocker-compose.yml
- Run following command:
docker-compose up -d
-
Deploy the
search-emp-micro
service:- Move to the directory
cd ../search-emp-micro
- Change
EC2_PUBLIC_URL=<ip or dns>
indocker-compose.yml
- Run following command:
docker-compose up -d
-
Verify that all services are running:
docker-compose ps
- To add an employee, access:
http://your-ec2-public-ip-or-dns
- After adding:
- To search for an employee, access:
http://your-ec2-public-ip-or-dns:8080
- After search:
Replace
your-ec2-public-ip-or-dns
with your actual EC2 instance's public IP or DNS.
If you encounter any issues:
-
Check the logs of the service:
docker-compose logs service-name
-
Ensure the database is properly initialized:
docker-compose exec db mysql -uroot -pabcd1234 -e "USE employee_db; SHOW TABLES;"
-
If needed, rebuild a service:
docker-compose up -d --build service-name
-
Pull the latest changes:
git pull origin main
-
Rebuild and restart the services:
docker-compose down docker-compose up -d --build
-
To backup the database:
docker-compose exec db mysqldump -u root -pabcd1234 employee_db > backup.sql
-
To restore the database:
cat backup.sql | docker exec -i container-name mysql -u root -pabcd1234 employee_db