Skip to content
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
5 changes: 2 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# test
FROM bitnami/tomcat
FROM bitnami/tomcat:latest
ENV ALLOW_EMPTY_PASSWORD=yes
COPY addressbook.war /opt/bitnami/tomcat/webapps_default/addressbook.war
COPY target/*.war /opt/bitnami/tomcat/webapps_default/addressbook.war
68 changes: 59 additions & 9 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -1,19 +1,69 @@
pipeline {
agent any

environment {
GIT_REPO = 'https://github.com/suhassg25/addressbook.git'
AWS_REGION = 'ap-south-1'
ECR_REPO = '409171460696.dkr.ecr.ap-south-1.amazonaws.com/jenkinsecr'
IMAGE_TAG = 'latest'
IMAGE_URI = "${ECR_REPO}:${IMAGE_TAG}"
EKS_CLUSTER = 'my-cluster'
}

stages {
stage('Compile') {
steps {
sh 'mvn compile'

stage('Clean Workspace') {
steps {
deleteDir()
}
}

stage('Clone') {
steps {
git url: "${GIT_REPO}", branch: 'master'
}
}

stage('Build') {
steps {
sh 'mvn clean package'
}
}

stage('Login to ECR') {
steps {
sh '''
aws ecr get-login-password --region $AWS_REGION \
| docker login --username AWS --password-stdin $ECR_REPO
'''
}
}

stage('Build Docker Image') {
steps {
sh 'docker build -t $IMAGE_URI .'
}
}
stage('test') {
steps {
sh 'mvn test'

stage('Push Image') {
steps {
sh 'docker push $IMAGE_URI'
}
}
stage('package') {
steps {
sh 'mvn package'

stage('Deploy to EKS') {
steps {
sh '''
echo "Current directory:"
pwd

echo "List files:"
ls -l
aws eks update-kubeconfig --region $AWS_REGION --name $EKS_CLUSTER

kubectl apply -f deployment.yaml
kubectl apply -f servicelb.yaml
'''
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions deployment.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# test

apiVersion: apps/v1
kind: Deployment
metadata:
Expand All @@ -19,7 +19,7 @@ spec:
app: mydeploy
spec:
containers:
- image: rajendrait99/addressbook:1.0
- image: 409171460696.dkr.ecr.ap-south-1.amazonaws.com/jenkinsecr:latest
name: addressbook
ports:
- containerPort: 8080
Expand Down
13 changes: 10 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<groupId>com.edurekademo.tutorial</groupId>
<artifactId>addressbook</artifactId>
<packaging>war</packaging>
<version>2.0</version>
<version>3.4</version>
<name>Vaadin Addressbook example</name>

<properties>
Expand Down Expand Up @@ -79,7 +79,7 @@
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.0.1</version>
<scope>compile</scope>
<scope>provided</scope>
</dependency>
<!-- The huge set of awesome Java libraries are available as such
for Vaadin developers, you should take the advantage of those. In this app
Expand Down Expand Up @@ -191,7 +191,14 @@
</excludes>
</configuration>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>3.4.0</version>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
</plugins>
<finalName>addressbook</finalName>
</build>
Expand Down
12 changes: 12 additions & 0 deletions service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
apiVersion: v1
kind: Service
metadata:
name: mydeploy-service
spec:
type: LoadBalancer
selector:
app: mydeploy
ports:
- protocol: TCP
port: 80
targetPort: 8080
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ public class ContactService {

// Create dummy data by randomly combining first and last names
static String[] fnames = { "Peter", "Alice", "John", "Mike", "Olivia",
"Nina", "Alex", "Rita", "Dan", "Umberto", "Henrik", "Rene", "Lisa",
"Nina", "Alex", "Riya", "Dan", "Umberto", "Henrik", "Rene", "Lisa",
"Linda", "Timothy", "Daniel", "Brian", "George", "Scott",
"Jennifer" };
"Jennifer, Lingaraj" };
static String[] lnames = { "Smith", "Johnson", "Williams", "Jones",
"Brown", "Davis", "Miller", "Wilson", "Moore", "Taylor",
"Anderson", "Thomas", "Jackson", "White", "Harris", "Martin",
"Thompson", "Young", "King", "Robinson" };
"Thompson", "Young", "King", "Robinson", hasan };

private static ContactService instance;

Expand Down
1 change: 1 addition & 0 deletions triggerSample.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
first trigger 11.01