{"id":19079076,"url":"https://github.com/abhixsh/employee-mgmt-dockerized","last_synced_at":"2026-04-14T04:31:00.516Z","repository":{"id":261000390,"uuid":"882943437","full_name":"abhixsh/employee-mgmt-dockerized","owner":"abhixsh","description":"A Dockerized MERN-based employee registration system featuring multi-stage builds, Docker Compose setup, and deployment using Azure cloud-native services.","archived":false,"fork":false,"pushed_at":"2024-12-07T02:29:37.000Z","size":17244,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-22T05:28:01.632Z","etag":null,"topics":["aws","docker","docker-compose","github-actions","mern-stack"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/abhixsh.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-11-04T04:56:04.000Z","updated_at":"2024-12-07T02:29:40.000Z","dependencies_parsed_at":"2024-12-06T03:22:13.754Z","dependency_job_id":"4b8670c2-97de-447b-864b-f51527a954da","html_url":"https://github.com/abhixsh/employee-mgmt-dockerized","commit_stats":null,"previous_names":["abhixsh/employee-mgmt-dockerized"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/abhixsh/employee-mgmt-dockerized","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abhixsh%2Femployee-mgmt-dockerized","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abhixsh%2Femployee-mgmt-dockerized/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abhixsh%2Femployee-mgmt-dockerized/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abhixsh%2Femployee-mgmt-dockerized/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/abhixsh","download_url":"https://codeload.github.com/abhixsh/employee-mgmt-dockerized/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abhixsh%2Femployee-mgmt-dockerized/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31782736,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-14T02:24:21.117Z","status":"ssl_error","status_checked_at":"2026-04-14T02:24:20.627Z","response_time":153,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["aws","docker","docker-compose","github-actions","mern-stack"],"created_at":"2024-11-09T02:13:15.473Z","updated_at":"2026-04-14T04:31:00.472Z","avatar_url":"https://github.com/abhixsh.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Employee Management System \n\n## Project Overview\nThe Employee Management System is a web application that uses the MERN stack (MongoDB, Express, React, Node.js) to manage employee data. It enables administrators to perform CRUD operations (Create, Read, Update, Delete) and features a React-powered responsive interface. The project is containerized using Docker for consistent deployment and integrated with GitHub Actions for automation.\n\n## Features\n- **User Authentication:** Admin and employee login.\n- **Employee Management:** Add, edit, and delete employee records.\n- **Department and Role Management:** Manage employee departments and roles.\n- **Search and Filter:** Search employees by various criteria.\n- **Responsive UI:** Built using React for a dynamic user interface.\n\n## Live Demo\nYou can try the live version of this project by visiting the following link: [Live Demo](#)\n\n\n## Technologies Used\n- **MongoDB:** NoSQL database to store employee information.\n- **Express.js:** Web framework for the backend API.\n- **React:** Frontend library for a dynamic user interface.\n- **Node.js:** JavaScript runtime for the backend.\n- **Docker:** Containerization for consistent deployment across environments.\n- **Nginx:** Web server to serve the React app in production.\n- **GitHub Action:** Automates testing and deployment pipelines.\n- **AWS:** For cloud deployment and container management.\n\n## Project Images\n![Landing Page](img/landing.png)\n![Senior Section](img/image-1.png)\n![Add Emp](img/image-2.png)\n![Add Emp](img/image-3.png)\n\n## Setup Guide\n\n### Step 1: Clone the Repository from GitHub\nClone the repository:\n\nOpen your terminal (or Git Bash if you're on Windows) and navigate to the directory where you want to store your project. Then, run the following command to clone your repository:\n\n```bash\ngit clone https://github.com/your-username/employee-mgmt-dockerized.git\n```\nReplace `your-username` with your GitHub username and `employee-mgmt-dockerized` with the name of your repository.\n\nNavigate to the project directory:\n\nAfter cloning, move into the project directory:\n\n```bash\ncd employee-mgmt-dockerized\n```\n\n### Step 2: Install Dependencies for the Backend\nNavigate to the backend directory (assuming your backend is in a folder called `backend`):\n\n```bash\ncd backend\n```\n\nInstall the backend dependencies:\n\nIf you're using npm for backend dependencies, run:\n\n```bash\nnpm install\n```\n\nThis will install all the required dependencies specified in the `package.json` file.\n\n### Step 3: Install Dependencies for the Frontend\nNavigate to the frontend directory (assuming your frontend is in a folder called `frontend`):\n\n```bash\ncd frontend\n```\n\nInstall the frontend dependencies:\n\nIf you're using npm for frontend dependencies, run:\n\n```bash\nnpm install\n```\n\n### Step 4: Run the Backend Locally\nNavigate back to the backend directory:\n\n```bash\ncd backend\n```\n\nStart the backend server:\n\nIf you're using npm, run:\n\n```bash\nnode server.js\n```\n\nThis will start the backend server. By default, the backend may run on port 5050. You can confirm this in your `server.js` file.\n\nVerify: The backend should now be accessible at [http://localhost:5050](http://localhost:5050).\n\n### Step 5: Run the Frontend Locally\nNavigate back to the frontend directory:\n\n```bash\ncd ../frontend\n```\n\nStart the frontend server:\n\nIf you're using npm, run:\n\n```bash\nnpm run dev\n```\n\nThis will start the frontend server, which by default will run on port 3000.\n\nVerify: The frontend should now be accessible at [http://localhost:3000](http://localhost:3000).\n\n### Step 6: Dockerize the Backend (Only Backend)\nTo Dockerize the backend, you'll create a Dockerfile in your backend directory.\n\n#### Step-by-Step:\n1. Navigate to your backend folder.\n2. Create a Dockerfile in the backend directory:\n\n```dockerfile\nFROM node:16\n\nWORKDIR /app\n\nCOPY package*.json ./\n\nRUN npm install\n\nCOPY . .\n\nEXPOSE 5050\n\nCMD [\"node\", \"server.js\"]\n```\n\n3. Build the Docker image:\nRun the following command in the terminal (from the backend directory):\n\n```bash\ndocker build -t my-backend .\n```\n\n4. Run the Docker container:\nAfter building the image, run the backend container:\n\n```bash\ndocker run -p 5050:5050 my-backend\n```\n\nThis will run your backend on port 5050.\n\n### Step 7: Multi-stage Build for Backend\nA multi-stage build allows you to create smaller images by having multiple stages in your Dockerfile.\n\n#### Step-by-Step:\n1. Modify your Dockerfile to use multi-stage builds:\n\n```dockerfile\n# Stage 1: Build\nFROM node:18-alpine AS build\nWORKDIR /app\nCOPY package*.json ./\nRUN npm install\nCOPY . .\n\n# Stage 2: Production\nFROM node:18-alpine\nWORKDIR /app\nCOPY --from=build /app /app\nENV NODE_ENV=production\nEXPOSE 5050\nCMD [\"node\", \"server.js\"]\n```\n\n2. Build the Docker image with multi-stage:\n\n```bash\ndocker build -t my-backend-multistage .\n```\n\n3. Run the container:\n\n```bash\ndocker run -p 5050:5050 my-backend-multistage\n```\n\n### Step 8: Push Image to Docker Hub (Only Backend)\nTo push the image to Docker Hub, follow these steps:\n\n1. Log in to Docker Hub in your terminal:\n\n```bash\ndocker login\n```\n\n2. Tag your image for Docker Hub:\nAssuming your Docker Hub username is `username` and the image name is `my-backend`:\n\n```bash\ndocker tag my-backend username/my-backend:latest\n```\n\n3. Push the image:\nPush the tagged image to Docker Hub:\n\n```bash\ndocker push username/my-backend:latest\n```\n\n### Step 9: Pull the NGINX Image from Docker Hub\nTo serve the React app, pull the latest official NGINX image from Docker Hub:\n\n```bash\ndocker pull nginx:latest\n```\n\n### Step 10: Build the React Frontend (if not already built)\nIf you haven't already built the React app, navigate to the frontend directory and build the React app:\n\n```bash\ncd path/to/your/frontend\nnpm run build\n```\n\nThis will create a `build/` directory in your frontend project that contains all the static files.\n\n### Step 11: Volume Map React Build Files to NGINX\nNow, we’ll run the NGINX container and map the volume to serve the React app's static files.\n\nRun the NGINX container and map volumes:\n\n```bash\ndocker run -d -p 3002:80 \\\n    -v ./employee-mgmt-dockerized/frontend/public/build:/usr/share/nginx/html \\\n    -v ./employee-mgmt-dockerized/frontend/nginx/nginx.conf:/etc/nginx/nginx.conf \\\n    nginx\n```\n\nVerify that the NGINX container is running by visiting [http://localhost](http://localhost) in your browser. Your React app should now be served by NGINX.\n\n### Step 12: Optional - Run Both Backend and Frontend with Docker Compose\nIf you want to run both the backend (Node.js) and frontend (NGINX) using Docker Compose, you can create a `docker-compose.yml` file to manage both services.\n\nCreate a `docker-compose.yml` file in your project root directory with the following content:\n\n```yaml\nversion: '3'\n\nservices:\n    backend:\n        image: emp-backend\n        build: ./backend\n        ports:\n            - \"5050:5050\"\n\n    frontend:\n        image: nginx\n        volumes:\n            - ./frontend/build:/usr/share/nginx/html\n            - ./frontend/nginx/nginx.conf:/etc/nginx/nginx.conf\n        ports:\n            - \"3000:80\"\n```\n\n#### Step-by-Step:\n1. Navigate to the project’s root directory.\n2. Run the Docker Compose services:\n\n```bash\ndocker-compose up --build\n```\n\nThis will start both the backend and the frontend in their respective containers. Your backend will be available at [http://localhost:5050](http://localhost:5050), and your frontend will be available at [http://localhost:3000](http://localhost:3000).\n\n### Step 13: Setup GitHub Action to Push Images to Docker Hub\n\nTo automate pushing Docker images of the backend and frontend to Docker Hub upon a push event in your GitHub repository, use the following GitHub Actions workflow. This ensures consistent builds and deployments from your repository.\n\n#### GitHub Actions Workflow: `backend-docker-push.yml`\n\nCreate a GitHub Actions workflow file in `.github/workflows/backend-docker-push.yml`:\n\n```yaml\nname: Backend and Frontend Docker Push\n\non: push\n\njobs:\n    test-backend:\n        runs-on: ubuntu-latest\n        steps:\n            - name: Checkout repository\n                uses: actions/checkout@v3\n            \n            - name: Install backend dependencies\n                run: |\n                    cd backend\n                    npm install\n\n    test-frontend:\n        runs-on: ubuntu-latest\n        steps:\n            - name: Checkout repository\n                uses: actions/checkout@v3\n\n            - name: Install frontend dependencies\n                run: |\n                    cd frontend\n                    npm install\n\n    docker-push:\n        needs: \n            - test-backend \n            - test-frontend\n        runs-on: ubuntu-latest\n        steps:\n            - name: Checkout repository\n                uses: actions/checkout@v3\n\n            - name: Build Docker images\n                run: |\n                    docker-compose build\n\n            - name: Log in to Docker Hub\n                run: |\n                    echo \"${{ secrets.DOCKER_PASSWORD }}\" | docker login -u \"${{ secrets.DOCKER_USERNAME }}\" --password-stdin\n\n            - name: Push Backend Image to Docker Hub\n                run: |\n                    docker tag emp-backend ${{ secrets.DOCKER_USERNAME }}/emp-backend:latest\n                    docker push ${{ secrets.DOCKER_USERNAME }}/emp-backend:latest\n\n            - name: Push Frontend Image to Docker Hub\n                run: |\n                    docker tag nginx ${{ secrets.DOCKER_USERNAME }}/emp-frontend:latest\n                    docker push ${{ secrets.DOCKER_USERNAME }}/emp-frontend:latest\n```\n\n#### Steps Explained:\n\n- **Trigger:** This workflow is triggered on any push to the main branch. Adjust the branch name as needed.\n- **Test Backend:** Installs and verifies the backend dependencies. [Optional]\n- **Test Frontend:** Installs and verifies the frontend dependencies. [Optional]\n- **Docker Build and Push:** After successfully testing, Docker images are built using `docker-compose` and pushed to Docker Hub using your saved credentials.\n\n#### Setting Up Secrets:\n\nTo store your Docker Hub credentials securely in the GitHub repository:\n\n1. Go to your repository's **Settings \u003e Secrets and variables \u003e Actions**.\n2. Add the following secrets:\n     - `DOCKER_USERNAME`: Your Docker Hub username.\n     - `DOCKER_PASSWORD`: Your Docker Hub password or access token.\n\n#### Verifying Workflow:\n\n1. Commit and push the `backend-docker-push.yml` file to your repository.\n2. Check the **Actions** tab in your GitHub repository to monitor the workflow's execution.\n3. Once complete, the backend and frontend Docker images will be available on Docker Hub under your account, tagged as `latest`.\n\n### Step 14: GitHub Action to Push Docker Images to ECR\n\nThis workflow pushes the backend Docker image to Amazon ECR.\n\n### GitHub Actions Workflow: `backend-docker-push-to-ecr.yml`\n\n```yaml\nname: Push Backend Docker Image to ECR\n\non:\n    push:\n        branches:\n            - main  # Adjust the branch name if needed\n\njobs:\n    build-and-push:\n        runs-on: ubuntu-latest\n\n        steps:\n            - name: Checkout repository\n                uses: actions/checkout@v3\n\n            - name: Set up Docker Buildx\n                uses: docker/setup-buildx-action@v2\n                # Allows for advanced Docker Build features\n\n            - name: Login to AWS ECR\n                run: |\n                    aws configure set aws_access_key_id ${{ secrets.AWS_ACCESS_KEY_ID }}\n                    aws configure set aws_secret_access_key ${{ secrets.AWS_SECRET_ACCESS_KEY }}\n                    aws configure set default.region ${{ secrets.AWS_DEFAULT_REGION }}\n                    aws ecr get-login-password --region ${{ secrets.AWS_DEFAULT_REGION }} | docker login --username AWS --password-stdin ${{ secrets.AWS_ACCOUNT_ID }}.dkr.ecr.${{ secrets.AWS_DEFAULT_REGION }}.amazonaws.com\n                # Logs into AWS ECR using AWS credentials stored in GitHub Secrets\n\n            - name: Build Docker Image\n                run: |\n                    docker-compose build backend\n                # Builds the Docker image for the backend from docker-compose.\n\n            - name: Tag Docker Image\n                run: |\n                    docker tag backend:latest ${{ secrets.AWS_ACCOUNT_ID }}.dkr.ecr.${{ secrets.AWS_DEFAULT_REGION }}.amazonaws.com/emp-backend:latest\n                # Tags the built backend Docker image.\n\n            - name: Push Backend Image to ECR\n                run: |\n                    docker push ${{ secrets.AWS_ACCOUNT_ID }}.dkr.ecr.${{ secrets.AWS_DEFAULT_REGION }}.amazonaws.com/emp-backend:latest\n                # Pushes the backend Docker image to ECR.\n```\n\n### Explanation:\n\n- This workflow is triggered on a push to the main branch.\n- It logs into AWS using credentials stored in GitHub Secrets (AWS Access Key, Secret Key, AWS Region, and Account ID).\n- It builds the backend Docker image and pushes it to an ECR repository (emp-backend).\n\n### Setting up AWS Secrets:\n\nGo to your repository’s **Settings \u003e Secrets and variables \u003e Actions** and add:\n\n- `AWS_ACCESS_KEY_ID`: Your AWS access key.\n- `AWS_SECRET_ACCESS_KEY`: Your AWS secret key.\n- `AWS_ACCOUNT_ID`: Your AWS account ID.\n- `AWS_DEFAULT_REGION`: The AWS region (e.g., us-west-2).\n\n### Step 15: GitHub Action for Dockerfile Vulnerability Scanning with Trivy\n\nThis workflow scans your Dockerfiles for security vulnerabilities using Trivy.\n\n### GitHub Actions Workflow: `docker-vulnerability-scan.yml`\n\n```yaml\nname: Scan Docker Images for Vulnerabilities\n\non:\n    push:\n        branches:\n            - main  # Adjust the branch name if needed\n\njobs:\n    vulnerability-scan:\n        runs-on: ubuntu-latest\n\n        steps:\n            - name: Checkout repository\n                uses: actions/checkout@v3\n\n            - name: Install Trivy\n                run: |\n                    sudo apt-get update\n                    sudo apt-get install -y wget\n                    wget https://github.com/aquasecurity/trivy/releases/download/v0.29.2/trivy_0.29.2_Linux-64bit.deb\n                    sudo dpkg -i trivy_0.29.2_Linux-64bit.deb\n                # Installs Trivy on the runner\n\n            - name: Scan Dockerfile for Vulnerabilities\n                run: |\n                    trivy fs --severity HIGH,CRITICAL --exit-code 1 --no-progress .\n                # Scans the repository's Dockerfiles for vulnerabilities. It exits with a non-zero code if high/critical vulnerabilities are found.\n```\n![alt text](img/image.png)\n### Explanation:\n\n- The workflow scans the Dockerfiles for vulnerabilities using Trivy.\n- If any critical or high vulnerabilities are found, it will fail the pipeline (exit-code 1).\n\n### Step 16: GitHub Action to Deploy Backend and Frontend to EC2\n\nThis workflow deploys your backend and frontend Docker containers to an EC2 instance using SSH.\n\n### GitHub Actions Workflow: `deploy-to-ec2.yml`\n\n```yaml\nname: Deploy to EC2\n\non:\n    push:\n        branches:\n            - main  # Trigger on push to main\n\njobs:\n    deploy:\n        runs-on: ubuntu-latest\n\n        steps:\n            - name: Checkout repository\n                uses: actions/checkout@v3\n\n            - name: Set up SSH for EC2\n                uses: webfactory/ssh-agent@v0.5.3\n                with:\n                    ssh-private-key: ${{ secrets.EC2_SSH_PRIVATE_KEY }}\n                # Configures SSH to communicate with EC2 using the private key stored in GitHub secrets.\n\n            - name: Copy Backend Docker Image to EC2\n                run: |\n                    ssh -o StrictHostKeyChecking=no ec2-user@${{ secrets.EC2_PUBLIC_IP }} \u003c\u003c 'EOF'\n                        docker pull ${{ secrets.AWS_ACCOUNT_ID }}.dkr.ecr.${{ secrets.AWS_DEFAULT_REGION }}.amazonaws.com/emp-backend:latest\n                        docker-compose -f /path/to/your/backend/docker-compose.yml up -d\n                    EOF\n                # Pulls the latest Docker image from ECR and deploys the backend to EC2 using `docker-compose`.\n\n            - name: Copy Frontend Docker Image to EC2\n                run: |\n                    ssh -o StrictHostKeyChecking=no ec2-user@${{ secrets.EC2_PUBLIC_IP }} \u003c\u003c 'EOF'\n                        docker pull ${{ secrets.AWS_ACCOUNT_ID }}.dkr.ecr.${{ secrets.AWS_DEFAULT_REGION }}.amazonaws.com/emp-frontend:latest\n                        docker-compose -f /path/to/your/frontend/docker-compose.yml up -d\n                    EOF\n                # Pulls the latest Docker image for the frontend and deploys it to EC2.\n```\n![alt text](img/ip.png)\n![alt text](img/ec2.png)\n### Explanation:\n\n- This workflow uses SSH to connect to your EC2 instance and deploys the backend and frontend Docker images pulled from ECR.\n- It assumes the `docker-compose.yml` file is present on the EC2 instance, which defines how to run the containers for both backend and frontend.\n\n### Setting up EC2 SSH Secrets:\n\nIn your repository's **Settings \u003e Secrets and variables \u003e Actions**, add the following secrets:\n\n- `EC2_SSH_PRIVATE_KEY`: Your private SSH key to access the EC2 instance.\n- `EC2_PUBLIC_IP`: The public IP address of your EC2 instance.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fabhixsh%2Femployee-mgmt-dockerized","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fabhixsh%2Femployee-mgmt-dockerized","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fabhixsh%2Femployee-mgmt-dockerized/lists"}