Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Docker and Jenkins File With Devsecops tools #5

Open
wants to merge 43 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
7943832
Update pom.xml
17J Apr 30, 2024
ffc1669
Create Dockerfile
17J Apr 30, 2024
6c3ebb1
Update Dockerfile
17J Apr 30, 2024
0f8b0b0
Update pom.xml
17J Apr 30, 2024
4475645
Jenkinfile Updated
17J Apr 30, 2024
95fc9e7
Update Jenkinsfile
17J Apr 30, 2024
abf7d4d
Dockerfile
17J Apr 30, 2024
d5bc165
Update Dockerfile
17J Apr 30, 2024
041c477
Update DBConnection.java
17J May 8, 2024
545181b
Create docker-compose.yml
17J May 8, 2024
d71b387
Update docker-compose.yml
17J May 8, 2024
d222c62
Update docker-compose.yml
17J May 8, 2024
adba33e
Update docker-compose.yml
17J May 8, 2024
f4c90c3
Update Dockerfile
17J May 8, 2024
fa38ddc
Create .env
17J May 8, 2024
00b601c
Update DBConnection.java
17J May 8, 2024
0f15c1a
Update DBConnection.java
17J May 9, 2024
af09913
Update Dockerfile
17J May 9, 2024
32a52ac
Update .env
17J May 9, 2024
acbeb8a
Update DBConnection.java
17J May 14, 2024
2c67631
Updated
Aug 22, 2024
24ac2b4
Updated
Aug 23, 2024
6ce1364
Updated
Aug 23, 2024
39f279b
Updated K8s
Aug 23, 2024
d1d971f
Update fullstack-db.yml
17J Aug 23, 2024
bbb9f8b
Update fullstack-db.yml
17J Aug 23, 2024
21a5567
Update Jenkinsfile
17J Aug 23, 2024
4c8a453
Update fullstack-db.yml
17J Aug 23, 2024
ef8a3fa
Update README.md
17J Aug 27, 2024
089b63a
Update fullstack-db.yml
17J Aug 28, 2024
56151ff
Update fullstack-db.yml
17J Aug 28, 2024
e787bbe
Update fullstack-db.yml
17J Aug 28, 2024
fcf2ff0
Update fullstack-db.yml
17J Aug 28, 2024
ee8d3a1
Update fullstack-db.yml
17J Aug 28, 2024
86094cf
Update fullstack-db.yml
17J Aug 28, 2024
eecfb6e
Update fullstack-db.yml
17J Aug 28, 2024
11b2fa0
Update fullstack-db.yml
17J Aug 28, 2024
58a0a9e
Update DBConnection.java
17J Sep 2, 2024
0ca59f3
Add files via upload
17J Sep 3, 2024
94111a1
main.tf
17J Sep 3, 2024
53357ea
Create output.tf
17J Sep 3, 2024
1dc989f
Create variables.tf
17J Sep 3, 2024
25dd34a
Update main.tf
17J Sep 3, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
MYSQL_HOST=172.31.28.241
MYSQL_USER=root
MYSQL_PASSWORD=root@@123
MYSQL_NAME=hms
MYSQL_ROOT_PASSWORD=root@@123
MYSQL_PORT=3306
33 changes: 33 additions & 0 deletions 1
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
services:
# Use a more descriptive service name
frontend:
build: ./Doctor-Patient-Portal # Build the frontend image from the current directory
ports:
- "8083:8083"
# Map container port 8085 to host port 8080 (standard HTTP)
environment:
- MYSQL_HOST=${MYSQL_HOST} # Use the service name of the database container
- MYSQL_NAME=${MYSQL_NAME} # Standard MySQL port # Add other environment variables from .env (see note)
- MYSQL_PASSWORD=${MYSQL_PASSWORD}
- MYSQL_USER=${MYSQL_USER}
depends_on:
- db # Ensure database is ready before starting frontend



# Use a more descriptive service name
db:
image: mysql:8.0 # Build the database image from the directory named 'db'
ports:
- "3306:3306"
environment:
- MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD} # Consider using a stronger password
- MYSQL_NAME=${MYSQL_NAME}
- MYSQL_PASSWORD=${MYSQL_PASSWORD}
volumes:
- ./init.sql:/docker-entrypoint-initdb.d/init.sql
healthcheck:
test: ["CMD","mysqladmin","ping"]
interval: 10s
timeout: 5s
retries: 3
10 changes: 10 additions & 0 deletions Doctor-Patient-Portal/1
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
FROM openjdk:17-alpine AS builder
RUN apk add --no-cache ca-certificates && update-ca-certificates
WORKDIR /app
RUN apk add --no-cache maven
COPY . .
RUN mvn clean package -DskipTests=true
FROM tomcat:9-alpine
COPY --from=builder /app/target/*.war /usr/local/tomcat/webapps/
EXPOSE 8080
CMD ["catalina.sh", "run"]
10 changes: 10 additions & 0 deletions Doctor-Patient-Portal/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
FROM openjdk:17-alpine AS builder
RUN apk add --no-cache ca-certificates && update-ca-certificates
WORKDIR /app
RUN apk add --no-cache maven
COPY . .
RUN mvn clean package -DskipTests=true
FROM tomcat:9-alpine
COPY --from=builder /app/target/*.war /usr/local/tomcat/webapps/
EXPOSE 8080
CMD ["catalina.sh", "run"]
115 changes: 115 additions & 0 deletions Doctor-Patient-Portal/Jenkinsfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
pipeline {
agent any

tools {
jdk 'jdk'
maven 'maven'
}

environment {
SCANNER_HOME= tool 'sonar-scanner'
}

stages {
stage('Git Checkout') {
steps {
echo 'git login'
git branch: 'main', changelog: false, poll: false, url: 'https://github.com/17J/Doctor-Patient-Portal-AdvanceJavaWebProject.git'
}
}
stage('Compile') {
steps {
dir('/var/lib/jenkins/workspace/doctor-portal/Doctor-Patient-Portal/') {
sh "mvn compile"
}
}
}
stage('Test') {
steps {
dir('/var/lib/jenkins/workspace/doctor-portal/Doctor-Patient-Portal/') {
sh "mvn test -DskipTests=true"
}
}
}
stage('File System Scan') {
steps {
sh "trivy fs --format table -o trivy-fs-report.html ."
}
}
stage('SonarQube Analsyis') {
steps {
withSonarQubeEnv('sonar-scanner') {
sh ''' $SCANNER_HOME/bin/sonar-scanner -Dsonar.projectName=doctor -Dsonar.projectKey=doctor \
-Dsonar.java.binaries=. '''
}
}
}
stage('Quality Gate') {
steps {
script {
waitForQualityGate abortPipeline: false, credentialsId: 'sonar-cred'
}
}
}
stage('Build') {
steps {
dir('/var/lib/jenkins/workspace/doctor-portal/Doctor-Patient-Portal/') {
sh "mvn package -DskipTests=true"
}
}
}
stage('Build & Tag Docker Image') {
steps {
script {
withDockerRegistry(credentialsId: 'docker-cred', toolName: 'docker') {
dir('/var/lib/jenkins/workspace/doctor-portal/Doctor-Patient-Portal/') {
sh "docker build -t maind ."
sh "docker tag maind 17rj/doctor-patient"
}


}
}
}
}
stage('Docker Image Scan') {
steps {
sh "trivy image --format table -o trivy-image-report.html 17rj/doctor-patient "
}
}
stage('Docker Image Push') {
steps {
script {
withDockerRegistry(credentialsId: 'docker-cred', toolName: 'docker') {
dir('/var/lib/jenkins/workspace/doctor-portal/Doctor-Patient-Portal/') {
sh "docker push 17rj/doctor-patient:latest"
}

}
}
}
}
stage('Deploy To Kubernetes') {
steps {
withKubeConfig(caCertificate: '', clusterName: 'main-eks17', contextName: '', credentialsId: 'kube-cred', namespace: 'webapps', restrictKubeConfigAccess: false, serverUrl: 'https://4D4C6465D0EABEF232FFC5BE0AA9F3B3.gr7.us-east-1.eks.amazonaws.com') {
dir('/var/lib/jenkins/workspace/doctor-portal/K8s/') {
sh "kubectl apply -f fullstack-db.yml -n webapps"
sh "kubectl apply -f fullstack-service-deployment.yml -n webapps"
sleep 60
}
}
}
}
stage('Verify To Kubernetes') {
steps {
withKubeConfig(caCertificate: '', clusterName: 'main-eks17', contextName: '', credentialsId: 'kube-cred', namespace: 'webapps', restrictKubeConfigAccess: false, serverUrl: 'https://4D4C6465D0EABEF232FFC5BE0AA9F3B3.gr7.us-east-1.eks.amazonaws.com') {

sh "kubectl get pods -n webapps"
sh "kubectl get svc -n webapps"


}
}
}
}
}
15 changes: 15 additions & 0 deletions Doctor-Patient-Portal/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,19 @@
</plugins>
<finalName>Doctor-Patient-Portal</finalName>
</build>
<properties>
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
</properties>
<distributionManagement>
<repository>
<id>maven-releases</id>
<url>http://34.207.189.118:8081/repository/maven-releases/</url>
</repository>
<snapshotRepository>
<id>maven-snapshots</id>
<url>http://34.207.189.118:8081/repository/maven-snapshots/</url>
</snapshotRepository>
</distributionManagement>

</project>
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public static Connection getConn() {
Class.forName("com.mysql.cj.jdbc.Driver");

//step:2- create a connection
conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/hospital","root","wasim");
conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/hms","root","root@@123");

} catch (Exception e) {
e.printStackTrace();
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

This file was deleted.

This file was deleted.

This file was deleted.

Loading