0% found this document useful (0 votes)
5 views

deploy_placement_batch_docker

This guide outlines the deployment process for the Placement-Batch project using Docker, covering the setup of both frontend (Angular) and backend (Spring Boot) Docker containers, as well as an Amazon RDS MySQL database. It includes detailed steps for installing Docker, creating Dockerfiles, using Docker Compose for container management, and automating the service with systemd. The final section confirms the successful deployment with testing instructions for the backend API and frontend application.

Uploaded by

santoshdhokare71
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views

deploy_placement_batch_docker

This guide outlines the deployment process for the Placement-Batch project using Docker, covering the setup of both frontend (Angular) and backend (Spring Boot) Docker containers, as well as an Amazon RDS MySQL database. It includes detailed steps for installing Docker, creating Dockerfiles, using Docker Compose for container management, and automating the service with systemd. The final section confirms the successful deployment with testing instructions for the backend API and frontend application.

Uploaded by

santoshdhokare71
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Docker-Based Deployment Guide for Placement-Batch Project

This guide provides a step-by-step deployment plan for hosting the Placement-Batch
It covers:
Frontend (Angular) Docker Container
Backend (Spring Boot) Docker Container
Database (Amazon RDS MySQL) Managed by AWS
Docker Compose for easy management

=====================================
1. INSTALL DOCKER & DOCKER COMPOSE
=====================================

Step 1: Install Docker


----------------------
sudo apt update && sudo apt install -y docker.io
sudo systemctl start docker
sudo systemctl enable docker

Step 2: Install Docker Compose


------------------------------
sudo curl -L "https://github.com/docker/compose/releases/latest/download/docker-co
sudo chmod +x /usr/local/bin/docker-compose
docker-compose --version

=====================================
2. DOCKERIZE BACKEND (SPRING BOOT)
=====================================

Step 1: Clone the Backend Repo


------------------------------
git clone https://github.com/rajatpzade/Placement-Batch.git
cd Placement-Batch/backend

Step 2: Create Dockerfile


-------------------------
FROM openjdk:17-jdk-slim
WORKDIR /app
COPY target/*.jar app.jar
EXPOSE 8080
CMD ["java", "-jar", "app.jar"]
Step 3: Update application.properties
-------------------------------------
spring.datasource.url=jdbc:mysql://your-rds-endpoint:3306/placement_batch
spring.datasource.username=placement_user
spring.datasource.password=securepassword

Step 4: Build & Run Docker Image


---------------------------------
mvn clean package
docker build -t placement-backend .
docker run -d -p 8080:8080 --name backend placement-backend

=====================================
3. DOCKERIZE FRONTEND (ANGULAR)
=====================================

Step 1: Clone the Frontend Repo


-------------------------------
cd ~
git clone https://github.com/rajatpzade/Placement-Batch.git
cd Placement-Batch/frontend

Step 2: Create Dockerfile


-------------------------
FROM node:18 as build
WORKDIR /app
COPY package.json package-lock.json ./
RUN npm install
COPY . .
RUN npm run build --configuration=production

FROM nginx:latest
COPY --from=build /app/dist/angular-frontend /usr/share/nginx/html
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]

Step 3: Update API Endpoint


---------------------------
nano src/environments/environment.prod.ts
Modify:
export const environment = {
production: true,
apiUrl: 'http://backend:8080/api'
};

Step 4: Build & Run Docker Image


---------------------------------
docker build -t placement-frontend .
docker run -d -p 80:80 --name frontend placement-frontend

=====================================
4. USING DOCKER COMPOSE
=====================================

Step 1: Create docker-compose.yml


---------------------------------
version: '3.8'

services:
backend:
build: ./backend
container_name: backend
ports:
- "8080:8080"
environment:
- SPRING_DATASOURCE_URL=jdbc:mysql://your-rds-endpoint:3306/placement_b
- SPRING_DATASOURCE_USERNAME=placement_user
- SPRING_DATASOURCE_PASSWORD=securepassword
depends_on:
- frontend

frontend:
build: ./frontend
container_name: frontend
ports:
- "80:80"
depends_on:
- backend

Step 2: Run Everything with One Command


---------------------------------------
docker-compose up -d

Step 3: Check Running Containers


--------------------------------
docker ps
=====================================
5. AUTOMATE WITH SYSTEMD
=====================================

Step 1: Create a systemd service


--------------------------------
sudo nano /etc/systemd/system/docker-compose-app.service

[Unit]
Description=Docker Compose App Service
After=network.target

[Service]
WorkingDirectory=/home/ubuntu/Placement-Batch
ExecStart=/usr/local/bin/docker-compose up -d
ExecStop=/usr/local/bin/docker-compose down
Restart=always

[Install]
WantedBy=multi-user.target

Step 2: Enable & Start


----------------------
sudo systemctl daemon-reload
sudo systemctl enable docker-compose-app
sudo systemctl start docker-compose-app

=====================================
6. FINAL TESTING
=====================================

Step 1: Verify Backend API


--------------------------
curl -X GET http://localhost:8080/api/test

Step 2: Verify Frontend


-----------------------
Open browser http://your-ec2-public-ip

=====================================
SUMMARY
=====================================

Amazon RDS MySQL Setup


Backend (Spring Boot) Dockerized
Frontend (Angular) Dockerized
Docker Compose for Managing Containers
Systemd for Auto-Start on Boot

=====================================
Your Placement-Batch Project is Fully Dockerized!
=====================================

You might also like