Skip to content

Local/dev test application #11

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

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
26 changes: 26 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: TestApplication
on: workflow_dispatch
env:
AWS_REGION: us-east-1
ECR_REPOSITORY: testapplication
EKS_CLUSTER: testapp-eks

jobs:
BUILD_AND_PUBLISH:
runs-on: ubuntu-latest
steps:
- name: Code checkout
uses: actions/checkout@v4

- name: Build & Upload image to ECR
uses: appleboy/docker-ecr-action@master
with:
access_key: ${{ secrets.AWS_ACCESS_KEY_ID }}
secret_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
registry: ${{ secrets.REGISTRY }}
repo: ${{ env.ECR_REPOSITORY }}
region: ${{ env.AWS_REGION }}
tags: latest,${{ github.run_number }}
daemon_off: false
dockerfile: ./Dockerfile
context: ./
10 changes: 5 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
FROM openjdk:11 AS BUILD_IMAGE
RUN apt update && apt install maven -y
COPY ./ vprofile-project
RUN cd vprofile-project && mvn install
COPY ./ testapp-project
RUN cd testapp-project && mvn install

FROM tomcat:9-jre11
LABEL "Project"="Vprofile"
LABEL "Author"="Imran"
LABEL "Project"="Testapp"
LABEL "Author"="George"
RUN rm -rf /usr/local/tomcat/webapps/*
COPY --from=BUILD_IMAGE vprofile-project/target/vprofile-v2.war /usr/local/tomcat/webapps/ROOT.war
COPY --from=BUILD_IMAGE testapp-project/target/testapp-v2.war /usr/local/tomcat/webapps/ROOT.war

EXPOSE 8080
CMD ["catalina.sh", "run"]
8 changes: 4 additions & 4 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ pipeline {
NEXUS_VERSION = "nexus3"
NEXUS_PROTOCOL = "http"
NEXUS_URL = "172.31.40.209:8081"
NEXUS_REPOSITORY = "vprofile-release"
NEXUS_REPO_ID = "vprofile-release"
NEXUS_REPOSITORY = "testapp-release"
NEXUS_REPO_ID = "testapp-release"
NEXUS_CREDENTIAL_ID = "nexuslogin"
ARTVERSION = "${env.BUILD_ID}"
}
Expand Down Expand Up @@ -62,8 +62,8 @@ pipeline {

steps {
withSonarQubeEnv('sonar-pro') {
sh '''${scannerHome}/bin/sonar-scanner -Dsonar.projectKey=vprofile \
-Dsonar.projectName=vprofile-repo \
sh '''${scannerHome}/bin/sonar-scanner -Dsonar.projectKey=testapp \
-Dsonar.projectName=testapp-repo \
-Dsonar.projectVersion=1.0 \
-Dsonar.sources=src/ \
-Dsonar.java.binaries=target/test-classes/com/visualpathit/account/controllerTest/ \
Expand Down
2 changes: 1 addition & 1 deletion ansible/site.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
- import_playbook: tomcat_setup.yml
- import_playbook: vpro-app-setup.yml
- import_playbook: testapp-app-setup.yml

###
4 changes: 2 additions & 2 deletions ansible/templates/application.j2
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@ rabbitmq.password=test
#Elasticesearch Configuration
elasticsearch.host =192.168.1.85
elasticsearch.port =9300
elasticsearch.cluster=vprofile
elasticsearch.node=vprofilenode
elasticsearch.cluster=testapp
elasticsearch.node=testappnode
10 changes: 5 additions & 5 deletions ansible/vpro-app-setup.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
vars:
timestamp: "{{ansible_date_time.date}}_{{ansible_date_time.hour}}_{{ansible_date_time.minute}}"
tasks:
- name: Download latest VProfile.war from nexus
- name: Download latest testapp.war from nexus
get_url:
url: "http://{{USER}}:{{PASS}}@{{nexusip}}:8081/repository/{{reponame}}/{{groupid}}/{{time}}/{{build}}/{{vprofile_version}}"
dest: "/tmp/vproapp-{{vprofile_version}}"
url: "http://{{USER}}:{{PASS}}@{{nexusip}}:8081/repository/{{reponame}}/{{groupid}}/{{time}}/{{build}}/{{testapp_version}}"
dest: "/tmp/testappapp-{{testapp_version}}"
register: wardeploy
tags:
- deploy
Expand Down Expand Up @@ -55,9 +55,9 @@

- name: Try deploy artifact else restore from previos old_ROOT
block:
- name: Deploy vprofile artifact
- name: Deploy testapp artifact
copy:
src: "/tmp/vproapp-{{vprofile_version}}"
src: "/tmp/testappapp-{{testapp_version}}"
dest: /usr/local/tomcat8/webapps/ROOT.war
remote_src: yes
register: deploy_info
Expand Down
6 changes: 3 additions & 3 deletions kubernetes/vpro-app/db-CIP.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
apiVersion: v1
kind: Service
metadata:
name: vprodb
name: testappdb
spec:
ports:
- port: 3306
targetPort: vprodb-port
targetPort: testappdb-port
protocol: TCP
selector:
app: vprodb
app: testappdb
type: ClusterIP
6 changes: 3 additions & 3 deletions kubernetes/vpro-app/mc-CIP.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
apiVersion: v1
kind: Service
metadata:
name: vprocache01
name: testappcache01
spec:
ports:
- port: 11211
targetPort: vpromc-port
targetPort: testappmc-port
protocol: TCP
selector:
app: vpromc
app: testappmc
type: ClusterIP
12 changes: 6 additions & 6 deletions kubernetes/vpro-app/mcdep.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: vpromc
name: testappmc
labels:
app: vpromc
app: testappmc
spec:
selector:
matchLabels:
app: vpromc
app: testappmc
replicas: 1
template:
metadata:
labels:
app: vpromc
app: testappmc
spec:
containers:
- name: vpromc
- name: testappmc
image: memcached
ports:
- name: vpromc-port
- name: testappmc-port
containerPort: 11211
6 changes: 3 additions & 3 deletions kubernetes/vpro-app/rmq-CIP-service.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
apiVersion: v1
kind: Service
metadata:
name: vpromq01
name: testappmq01
spec:
ports:
- port: 5672
targetPort: vpromq01-port
targetPort: testappmq01-port
protocol: TCP
selector:
app: vpromq01
app: testappmq01
type: ClusterIP
12 changes: 6 additions & 6 deletions kubernetes/vpro-app/rmq-dep.yml
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: vpromq01
name: testappmq01
labels:
app: vpromq01
app: testappmq01
spec:
selector:
matchLabels:
app: vpromq01
app: testappmq01
replicas: 1
template:
metadata:
labels:
app: vpromq01
app: testappmq01
spec:
containers:
- name: vpromq01
- name: testappmq01
image: rabbitmq
ports:
- name: vpromq01-port
- name: testappmq01-port
containerPort: 15672
env:
- name: RABBITMQ_DEFAULT_PASS
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ spec:
protocol: TCP
targetPort: 8080
selector:
app: vproapp
app: testapp
type: ClusterIP
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: vprodb
name: testappdb
labels:
app: vprodb
app: testappdb
spec:
selector:
matchLabels:
app: vprodb
app: testappdb
replicas: 1
template:
metadata:
labels:
app: vprodb
app: testappdb
spec:
containers:
- name: vprodb
image: vprofile/vprofiledb
- name: testappdb
image: testapp/testappdb
ports:
- name: vprodb-port
- name: testappdb-port
containerPort: 3306
env:
- name: MYSQL_ROOT_PASSWORD
Expand All @@ -28,5 +28,5 @@ spec:
key: db-pass
# env:
# - name: MYSQL_ROOT_PASSWORD
# value: "vprodbpass"
# value: "testappdbpass"

29 changes: 29 additions & 0 deletions kubernetes/vpro-app/testappdep.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: testapp
labels:
app: testapp
spec:
replicas: 1
selector:
matchLabels:
app: testapp
template:
metadata:
labels:
app: testapp
spec:
containers:
- name: testapp
image: testapp-project/testapp
ports:
- name: testapp-port
containerPort: 8080
initContainers:
- name: init-mydb
image: busybox
command: ['sh', '-c', 'until nslookup testappdb.$(cat /var/run/secrets/kubernetes.io/serviceaccount/namespace).svc.cluster.local; do echo waiting for mydb; sleep 2; done;']
- name: init-memcache
image: busybox
command: ['sh', '-c', 'until nslookup testappcache01.$(cat /var/run/secrets/kubernetes.io/serviceaccount/namespace).svc.cluster.local; do echo waiting for mydb; sleep 2; done;']
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: vpro-ingress
name: testapp-ingress
annotations:
nginx.ingress.kubernetes.io/use-regex: "true"
spec:
ingressClassName: nginx
rules:
- host: vprofile.thehkh.com
- host: testapp.thehkh.com
http:
paths:
- path: /
Expand Down
18 changes: 9 additions & 9 deletions kubernetes/vpro-app/vproappdep.yml
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: vproapp
name: testapp
labels:
app: vproapp
app: testapp
spec:
replicas: 1
selector:
matchLabels:
app: vproapp
app: testapp
template:
metadata:
labels:
app: vproapp
app: testapp
spec:
containers:
- name: vproapp
image: vprofile/vprofileapp
- name: testapp
image: testapp/testapp
ports:
- name: vproapp-port
- name: testapp-port
containerPort: 8080
initContainers:
- name: init-mydb
image: busybox
command: ['sh', '-c', 'until nslookup vprodb.$(cat /var/run/secrets/kubernetes.io/serviceaccount/namespace).svc.cluster.local; do echo waiting for mydb; sleep 2; done;']
command: ['sh', '-c', 'until nslookup testappdb.$(cat /var/run/secrets/kubernetes.io/serviceaccount/namespace).svc.cluster.local; do echo waiting for mydb; sleep 2; done;']
- name: init-memcache
image: busybox
command: ['sh', '-c', 'until nslookup vprocache01.$(cat /var/run/secrets/kubernetes.io/serviceaccount/namespace).svc.cluster.local; do echo waiting for mydb; sleep 2; done;']
command: ['sh', '-c', 'until nslookup testappcache01.$(cat /var/run/secrets/kubernetes.io/serviceaccount/namespace).svc.cluster.local; do echo waiting for mydb; sleep 2; done;']
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.visualpathit</groupId>
<artifactId>vprofile</artifactId>
<artifactId>testapp</artifactId>
<packaging>war</packaging>
<version>v2</version>
<name>Visualpathit VProfile Webapp</name>
Expand Down
16 changes: 8 additions & 8 deletions src/main/resources/application.properties
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
#JDBC Configutation for Database Connection
jdbc.driverClassName=com.mysql.jdbc.Driver
jdbc.url=jdbc:mysql://vprodb:3306/accounts?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull
jdbc.url=jdbc:mysql://testappdb:3306/accounts?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull
jdbc.username=root
jdbc.password=vprodbpass
jdbc.password=testappdbpass

#Memcached Configuration For Active and StandBy Host
#For Active Host
memcached.active.host=vprocache01
memcached.active.host=testapcache01
memcached.active.port=11211
#For StandBy Host
memcached.standBy.host=vprocache02
memcached.standBy.host=testappcache02
memcached.standBy.port=11211

#RabbitMq Configuration
rabbitmq.address=vpromq01
rabbitmq.address=testappmq01
rabbitmq.port=15672
rabbitmq.username=guest
rabbitmq.password=guest

#Elasticesearch Configuration
elasticsearch.host =vprosearch01
elasticsearch.host =testappsearch01
elasticsearch.port =9300
elasticsearch.cluster=vprofile
elasticsearch.node=vprofilenode
elasticsearch.cluster=testapp
elasticsearch.node=testappnode