Skip to content

Commit 505f366

Browse files
committed
workflow
0 parents  commit 505f366

File tree

94 files changed

+13171
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

94 files changed

+13171
-0
lines changed

.github/workflows/ecs.yml

+59
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
name: Pitapitapitaboo Workflow
2+
on: workflow_dispatch
3+
env:
4+
AWS_REGION: us-east-2 # set this to your preferred AWS region, e.g. us-west-1
5+
ECR_REPOSITORY: actapp # set this to your Amazon ECR repository name
6+
ECS_SERVICE: vproappsvc32 # set this to your Amazon ECS service name
7+
ECS_CLUSTER: vprostaging32 # set this to your Amazon ECS cluster name
8+
ECS_TASK_DEFINITION: aws-files/taskdeffile.json # set this to the path to your Amazon ECS task definition # file, e.g. .aws/task-definition.json
9+
CONTAINER_NAME: vproapp # set this to the name of the container in the
10+
# containerDefinitions section of your task definition
11+
jobs:
12+
Build_And_Publish:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Code checkout
16+
uses: actions/checkout@v4
17+
18+
- name: Update application.properties file
19+
run: |
20+
sed -i "s/^jdbc.username.*$/jdbc.username\=${{ secrets.RDS_USER }}/" src/main/resources/application.properties
21+
sed -i "s/^jdbc.password.*$/jdbc.password\=${{ secrets.RDS_PASS }}/" src/main/resources/application.properties
22+
sed -i "s/db01/${{ secrets.RDS_ENDPOINT }}/" src/main/resources/application.properties
23+
cat src/main/resources/application.properties
24+
25+
- name: Build & Upload image to ECR
26+
uses: appleboy/docker-ecr-action@master
27+
with:
28+
access_key: ${{ secrets.AWS_ACCESS_KEY_ID }}
29+
secret_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
30+
registry: ${{ secrets.REGISTRY }}
31+
repo: actapp
32+
region: ${{ env.AWS_REGION }}
33+
tags: latest,${{ github.run_number }}
34+
daemon_off: false
35+
dockerfile: ./Dockerfile
36+
context: ./
37+
38+
- name: Configure AWS credentials
39+
uses: aws-actions/configure-aws-credentials@0e613a0980cbf65ed5b322eb7a1e075d28913a83
40+
with:
41+
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
42+
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
43+
aws-region: ${{ env.AWS_REGION }}
44+
45+
- name: Fill in the new image ID in the Amazon ECS task definition
46+
id: task-def
47+
uses: aws-actions/amazon-ecs-render-task-definition@c804dfbdd57f713b6c079302a4c01db7017a36fc
48+
with:
49+
task-definition: ${{ env.ECS_TASK_DEFINITION }}
50+
container-name: ${{ env.CONTAINER_NAME }}
51+
image: ${{ secrets.REGISTRY }}/${{ env.ECR_REPOSITORY }}:${{ github.run_number }}
52+
53+
- name: Deploy Amazon ECS task definition
54+
uses: aws-actions/amazon-ecs-deploy-task-definition@df9643053eda01f169e64a0e60233aacca83799a
55+
with:
56+
task-definition: ${{ steps.task-def.outputs.task-definition }}
57+
service: ${{ env.ECS_SERVICE }}
58+
cluster: ${{ env.ECS_CLUSTER }}
59+
wait-for-service-stability: true

.github/workflows/pikabo.yml

+108
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
name: Pikabo Workflow
2+
on: workflow_dispatch
3+
env:
4+
AWS_REGION: us-east-2 # set this to your preferred AWS region, e.g. us-west-1
5+
ECR_REPOSITORY: actapp # set this to your Amazon ECR repository name
6+
ECS_SERVICE: vproappsvc32 # set this to your Amazon ECS service name
7+
ECS_CLUSTER: vprostaging32 # set this to your Amazon ECS cluster name
8+
ECS_TASK_DEFINITION: aws-files/taskdeffile.json # set this to the path to your Amazon ECS task definition # file, e.g. .aws/task-definition.json
9+
CONTAINER_NAME: vproapp # set this to the name of the container in the
10+
jobs:
11+
Testing:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Code checkout
15+
uses: actions/checkout@v4
16+
17+
- name: Maven test
18+
run: mvn test
19+
20+
- name: Checkstyle
21+
run: mvn checkstyle:checkstyle
22+
23+
# Setup java 11 to be default (sonar-scanner requirement as of 5.x)
24+
- uses: actions/setup-java@v3
25+
with:
26+
distribution: 'temurin' # See 'Supported distributions' for available options
27+
java-version: '11'
28+
29+
# Setup sonar-scanner
30+
- name: Setup SonarQube
31+
uses: warchant/setup-sonar-scanner@v7
32+
33+
# Run sonar-scanner
34+
- name: SonarQube Scan
35+
run: sonar-scanner
36+
-Dsonar.host.url=${{ secrets.SONAR_URL }}
37+
-Dsonar.login=${{ secrets.SONAR_TOKEN }}
38+
-Dsonar.organization=${{ secrets.SONAR_ORGANIZATION }}
39+
-Dsonar.projectKey=${{ secrets.SONAR_PROJECT_KEY }}
40+
-Dsonar.sources=src/
41+
-Dsonar.junit.reportsPath=target/surefire-reports/
42+
-Dsonar.jacoco.reportsPath=target/jacoco.exec
43+
-Dsonar.java.checkstyle.reportPaths=target/checkstyle-result.xml
44+
-Dsonar.java.binaries=target/test-classes/com/visualpathit/account/controllerTest/
45+
46+
- name: SonarQube Quality Gate check
47+
id: sonarqube-quality-gate-check
48+
uses: sonarsource/sonarqube-quality-gate-action@master
49+
# Force to fail step after specific time.
50+
timeout-minutes: 5
51+
env:
52+
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
53+
SONAR_HOST_URL: ${{ secrets.SONAR_URL }} #OPTIONAL
54+
55+
Build_And_Publish:
56+
needs: Testing
57+
runs-on: ubuntu-latest
58+
steps:
59+
- name: Code checkout
60+
uses: actions/checkout@v4
61+
62+
- name: Update application.properties file
63+
run: |
64+
sed -i "s/^jdbc.username.*$/jdbc.username\=${{ secrets.RDS_USER }}/" src/main/resources/application.properties
65+
sed -i "s/^jdbc.password.*$/jdbc.password\=${{ secrets.RDS_PASS }}/" src/main/resources/application.properties
66+
sed -i "s/db01/${{ secrets.RDS_ENDPOINT }}/" src/main/resources/application.properties
67+
cat src/main/resources/application.properties
68+
69+
- name: Build & Upload image to ECR
70+
uses: appleboy/docker-ecr-action@master
71+
with:
72+
access_key: ${{ secrets.AWS_ACCESS_KEY_ID }}
73+
secret_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
74+
registry: ${{ secrets.REGISTRY }}
75+
repo: actapp
76+
region: ${{ env.AWS_REGION }}
77+
tags: latest,${{ github.run_number }}
78+
daemon_off: false
79+
dockerfile: ./Dockerfile
80+
context: ./
81+
82+
Deploy:
83+
needs: Build_And_Publish
84+
runs-on: ubuntu-latest
85+
steps:
86+
- name: Configure AWS credentials
87+
uses: aws-actions/configure-aws-credentials@0e613a0980cbf65ed5b322eb7a1e075d28913a83
88+
with:
89+
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
90+
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
91+
aws-region: ${{ env.AWS_REGION }}
92+
93+
- name: Fill in the new image ID in the Amazon ECS task definition
94+
id: task-def
95+
uses: aws-actions/amazon-ecs-render-task-definition@c804dfbdd57f713b6c079302a4c01db7017a36fc
96+
with:
97+
task-definition: ${{ env.ECS_TASK_DEFINITION }}
98+
container-name: ${{ env.CONTAINER_NAME }}
99+
image: ${{ secrets.REGISTRY }}/${{ env.ECR_REPOSITORY }}:${{ github.run_number }}
100+
101+
- name: Deploy Amazon ECS task definition
102+
uses: aws-actions/amazon-ecs-deploy-task-definition@df9643053eda01f169e64a0e60233aacca83799a
103+
with:
104+
task-definition: ${{ steps.task-def.outputs.task-definition }}
105+
service: ${{ env.ECS_SERVICE }}
106+
cluster: ${{ env.ECS_CLUSTER }}
107+
wait-for-service-stability: true
108+

Dockerfile

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
FROM openjdk:11 AS BUILD_IMAGE
2+
RUN apt update && apt install maven -y
3+
COPY ./ vprofile-project
4+
RUN cd vprofile-project && mvn install
5+
6+
FROM tomcat:9-jre11
7+
LABEL "Project"="Vprofile"
8+
LABEL "Author"="Imran"
9+
RUN rm -rf /usr/local/tomcat/webapps/*
10+
COPY --from=BUILD_IMAGE vprofile-project/target/vprofile-v2.war /usr/local/tomcat/webapps/ROOT.war
11+
12+
EXPOSE 8080
13+
CMD ["catalina.sh", "run"]

Jenkinsfile

+122
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
pipeline {
2+
3+
agent any
4+
/*
5+
tools {
6+
maven "maven3"
7+
8+
}
9+
*/
10+
environment {
11+
NEXUS_VERSION = "nexus3"
12+
NEXUS_PROTOCOL = "http"
13+
NEXUS_URL = "172.31.40.209:8081"
14+
NEXUS_REPOSITORY = "vprofile-release"
15+
NEXUS_REPO_ID = "vprofile-release"
16+
NEXUS_CREDENTIAL_ID = "nexuslogin"
17+
ARTVERSION = "${env.BUILD_ID}"
18+
}
19+
20+
stages{
21+
22+
stage('BUILD'){
23+
steps {
24+
sh 'mvn clean install -DskipTests'
25+
}
26+
post {
27+
success {
28+
echo 'Now Archiving...'
29+
archiveArtifacts artifacts: '**/target/*.war'
30+
}
31+
}
32+
}
33+
34+
stage('UNIT TEST'){
35+
steps {
36+
sh 'mvn test'
37+
}
38+
}
39+
40+
stage('INTEGRATION TEST'){
41+
steps {
42+
sh 'mvn verify -DskipUnitTests'
43+
}
44+
}
45+
46+
stage ('CODE ANALYSIS WITH CHECKSTYLE'){
47+
steps {
48+
sh 'mvn checkstyle:checkstyle'
49+
}
50+
post {
51+
success {
52+
echo 'Generated Analysis Result'
53+
}
54+
}
55+
}
56+
57+
stage('CODE ANALYSIS with SONARQUBE') {
58+
59+
environment {
60+
scannerHome = tool 'sonarscanner4'
61+
}
62+
63+
steps {
64+
withSonarQubeEnv('sonar-pro') {
65+
sh '''${scannerHome}/bin/sonar-scanner -Dsonar.projectKey=vprofile \
66+
-Dsonar.projectName=vprofile-repo \
67+
-Dsonar.projectVersion=1.0 \
68+
-Dsonar.sources=src/ \
69+
-Dsonar.java.binaries=target/test-classes/com/visualpathit/account/controllerTest/ \
70+
-Dsonar.junit.reportsPath=target/surefire-reports/ \
71+
-Dsonar.jacoco.reportsPath=target/jacoco.exec \
72+
-Dsonar.java.checkstyle.reportPaths=target/checkstyle-result.xml'''
73+
}
74+
75+
timeout(time: 10, unit: 'MINUTES') {
76+
waitForQualityGate abortPipeline: true
77+
}
78+
}
79+
}
80+
81+
stage("Publish to Nexus Repository Manager") {
82+
steps {
83+
script {
84+
pom = readMavenPom file: "pom.xml";
85+
filesByGlob = findFiles(glob: "target/*.${pom.packaging}");
86+
echo "${filesByGlob[0].name} ${filesByGlob[0].path} ${filesByGlob[0].directory} ${filesByGlob[0].length} ${filesByGlob[0].lastModified}"
87+
artifactPath = filesByGlob[0].path;
88+
artifactExists = fileExists artifactPath;
89+
if(artifactExists) {
90+
echo "*** File: ${artifactPath}, group: ${pom.groupId}, packaging: ${pom.packaging}, version ${pom.version} ARTVERSION";
91+
nexusArtifactUploader(
92+
nexusVersion: NEXUS_VERSION,
93+
protocol: NEXUS_PROTOCOL,
94+
nexusUrl: NEXUS_URL,
95+
groupId: pom.groupId,
96+
version: ARTVERSION,
97+
repository: NEXUS_REPOSITORY,
98+
credentialsId: NEXUS_CREDENTIAL_ID,
99+
artifacts: [
100+
[artifactId: pom.artifactId,
101+
classifier: '',
102+
file: artifactPath,
103+
type: pom.packaging],
104+
[artifactId: pom.artifactId,
105+
classifier: '',
106+
file: "pom.xml",
107+
type: "pom"]
108+
]
109+
);
110+
}
111+
else {
112+
error "*** File: ${artifactPath}, could not be found";
113+
}
114+
}
115+
}
116+
}
117+
118+
119+
}
120+
121+
122+
}

README.md

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Prerequisites
2+
#
3+
- JDK 11
4+
- Maven 3 or later
5+
- MySQL 5.6 or later
6+
7+
# Technologies
8+
- Spring MVC
9+
- Spring Security
10+
- Spring Data JPA
11+
- Maven
12+
- JSP
13+
- MySQL
14+
# Database
15+
Here,we used Mysql DB
16+
MSQL DB Installation Steps for Linux ubuntu 14.04:
17+
- $ sudo apt-get update
18+
- $ sudo apt-get install mysql-server
19+
20+
Then look for the file :
21+
- /src/main/resources/accountsdb
22+
- accountsdb.sql file is a mysql dump file.we have to import this dump to mysql db server
23+
- > mysql -u <user_name> -p accounts < accountsdb.sql
24+
25+

ansible/ansible.cfg

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[defaults]
2+
host_key_checking = False
3+
timeout = 30

ansible/site.yml

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
- import_playbook: tomcat_setup.yml
3+
- import_playbook: vpro-app-setup.yml
4+
5+
###

ansible/templates/application.j2

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#JDBC Configutation for Database Connection
2+
jdbc.driverClassName=com.mysql.jdbc.Driver
3+
jdbc.url=jdbc:mysql://dbhost:3306/accounts?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull
4+
jdbc.username=db_user
5+
jdbc.password=db_password
6+
7+
#Memcached Configuration For Active and StandBy Host
8+
#For Active Host
9+
memcached.active.host=127.0.0.1
10+
memcached.active.port=11211
11+
#For StandBy Host
12+
memcached.standBy.host=127.0.0.2
13+
memcached.standBy.port=11211
14+
15+
#RabbitMq Configuration
16+
rabbitmq.address=18.220.62.126
17+
rabbitmq.port=5672
18+
rabbitmq.username=test
19+
rabbitmq.password=test
20+
21+
#Elasticesearch Configuration
22+
elasticsearch.host =192.168.1.85
23+
elasticsearch.port =9300
24+
elasticsearch.cluster=vprofile
25+
elasticsearch.node=vprofilenode

0 commit comments

Comments
 (0)