From bdc48c31d6edba1b556d76b21e8c2cd94538f3f2 Mon Sep 17 00:00:00 2001 From: sharvis8 <154662261+sharvis8@users.noreply.github.com> Date: Sun, 31 Dec 2023 13:52:16 +0530 Subject: [PATCH 01/18] Added Jenkinsfile --- Jenkinsfile | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 Jenkinsfile diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 0000000..8b82bf6 --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,11 @@ +pipeline { + agent any + stages { + stage('checkout') { + steps { + git(url: 'https://github.com/sharvis8/simple-webserver-golang', branch: 'main') + } + } + + } +} \ No newline at end of file From 4ba90042cb9171b70bb20d3f69441eb2d5fec080 Mon Sep 17 00:00:00 2001 From: sharvis8 <154662261+sharvis8@users.noreply.github.com> Date: Sun, 31 Dec 2023 13:58:48 +0530 Subject: [PATCH 02/18] listing files --- Jenkinsfile | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Jenkinsfile b/Jenkinsfile index 8b82bf6..155e18b 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -7,5 +7,11 @@ pipeline { } } + stage('') { + steps { + sh 'ls -la' + } + } + } } \ No newline at end of file From 44e3ee0eb789ccbf44af3bba2bff920db66853f6 Mon Sep 17 00:00:00 2001 From: sharvis8 <154662261+sharvis8@users.noreply.github.com> Date: Sun, 31 Dec 2023 14:04:13 +0530 Subject: [PATCH 03/18] Added Jenkinsfile --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 155e18b..30340b0 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -7,7 +7,7 @@ pipeline { } } - stage('') { + stage('Listing files') { steps { sh 'ls -la' } From 653b138a00776048c90a7d4085306c613c27b2d8 Mon Sep 17 00:00:00 2001 From: sharvis8 <154662261+sharvis8@users.noreply.github.com> Date: Sun, 31 Dec 2023 14:10:27 +0530 Subject: [PATCH 04/18] new empty file --- Jenkinsfile | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Jenkinsfile b/Jenkinsfile index 30340b0..797a36d 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -13,5 +13,11 @@ pipeline { } } + stage('') { + steps { + sh 'touch emptyFile' + } + } + } } \ No newline at end of file From e47911b03dece33a2c719e5056c82c95e318d797 Mon Sep 17 00:00:00 2001 From: sharvis8 <154662261+sharvis8@users.noreply.github.com> Date: Sun, 31 Dec 2023 15:37:49 +0530 Subject: [PATCH 05/18] Added Jenkinsfile --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 797a36d..73e1f83 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -13,7 +13,7 @@ pipeline { } } - stage('') { + stage('new empty file') { steps { sh 'touch emptyFile' } From 111c6d9d4daded368f1585989e90f0bb40841932 Mon Sep 17 00:00:00 2001 From: sharvis8 <154662261+sharvis8@users.noreply.github.com> Date: Sun, 31 Dec 2023 15:59:31 +0530 Subject: [PATCH 06/18] Create Dockerfile --- Dockerfile | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..001bae0 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,13 @@ +FROM golang:latest + +RUN mkdir /app + +ADD . /app + +WORKDIR /app + +RUN go build -o main . + +EXPOSE 8080 + +CMD [ "/app/main" ] From e4c6c58d20ff14a4b9f866e0608d0125481f58d2 Mon Sep 17 00:00:00 2001 From: sharvis8 <154662261+sharvis8@users.noreply.github.com> Date: Sun, 31 Dec 2023 16:02:12 +0530 Subject: [PATCH 07/18] Update Dockerfile --- Dockerfile | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index 001bae0..653f9f3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,12 +2,10 @@ FROM golang:latest RUN mkdir /app -ADD . /app +COPY . /app WORKDIR /app RUN go build -o main . -EXPOSE 8080 - CMD [ "/app/main" ] From 9a6382b869c55c490a9dbca63668476ab34e75f4 Mon Sep 17 00:00:00 2001 From: sharvis8 <154662261+sharvis8@users.noreply.github.com> Date: Sun, 31 Dec 2023 16:13:35 +0530 Subject: [PATCH 08/18] Update Dockerfile --- Dockerfile | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index 653f9f3..2de418d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -6,6 +6,4 @@ COPY . /app WORKDIR /app -RUN go build -o main . - -CMD [ "/app/main" ] +CMD go run main.go From 3ed46cda9f9820cc69e4b2a0fda4662e26c0ef74 Mon Sep 17 00:00:00 2001 From: sharvis8 <154662261+sharvis8@users.noreply.github.com> Date: Sun, 31 Dec 2023 16:15:35 +0530 Subject: [PATCH 09/18] Dockerlize --- Jenkinsfile | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Jenkinsfile b/Jenkinsfile index 73e1f83..c200140 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -19,5 +19,11 @@ pipeline { } } + stage('') { + steps { + sh 'docker build -t simplegolang .' + } + } + } } \ No newline at end of file From fb8570731df5345645299b084eb120db301af11f Mon Sep 17 00:00:00 2001 From: sharvis8 <154662261+sharvis8@users.noreply.github.com> Date: Sun, 31 Dec 2023 16:39:40 +0530 Subject: [PATCH 10/18] DockerLogin --- Jenkinsfile | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index c200140..42b82ff 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -19,11 +19,21 @@ pipeline { } } - stage('') { + stage('DockerBuild') { steps { sh 'docker build -t simplegolang .' } } + stage('DockerLogin') { + environment { + DOCKERHUB_USER = 'sharvis8' + DOCKERHUB_PASSWORD = 'Vantage@#456' + } + steps { + sh 'docker login -u $DOCKERHUB_USER -p $DOCKERHUB_PASSWORD' + } + } + } } \ No newline at end of file From c922a18e273759e8ae2690c2541689d6de865e54 Mon Sep 17 00:00:00 2001 From: sharvis8 <154662261+sharvis8@users.noreply.github.com> Date: Sun, 31 Dec 2023 16:42:16 +0530 Subject: [PATCH 11/18] Push --- Jenkinsfile | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Jenkinsfile b/Jenkinsfile index 42b82ff..30aae6a 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -35,5 +35,11 @@ pipeline { } } + stage('Dockerhub Push') { + steps { + sh 'docker push sharvis8/simplegolang:latest' + } + } + } } \ No newline at end of file From 4cf2f25f180ab72898ea1306402ebe15b643574d Mon Sep 17 00:00:00 2001 From: sharvis8 <154662261+sharvis8@users.noreply.github.com> Date: Sun, 31 Dec 2023 16:44:49 +0530 Subject: [PATCH 12/18] added tag in build --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 30aae6a..72ceb8a 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -21,7 +21,7 @@ pipeline { stage('DockerBuild') { steps { - sh 'docker build -t simplegolang .' + sh 'docker build -t simplegolang . -t sharvis8/simplegolang:latest' } } From d0e990adf2e8f70ef939c8b5f61f0872bed5c03f Mon Sep 17 00:00:00 2001 From: sharvis8 <154662261+sharvis8@users.noreply.github.com> Date: Mon, 1 Jan 2024 20:59:03 +0530 Subject: [PATCH 13/18] Create Deployment.yaml --- Deployment.yaml | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 Deployment.yaml diff --git a/Deployment.yaml b/Deployment.yaml new file mode 100644 index 0000000..b9b1a81 --- /dev/null +++ b/Deployment.yaml @@ -0,0 +1,20 @@ +apiVersion: app/v1 +kind: Deployment +metadata: + name: my-deployment + labels: + app: golang +spec: + selector: + matchLabels: + app: myapp + replicas: 4 + template: + metadata: + name: golang-2 + labels: + app: myapp + spec: + containers: + - name: golang + image: sharvis8/simplegolang:latest From 6fc12af3f6161e637f75bc64355608a29af79c92 Mon Sep 17 00:00:00 2001 From: sharvis8 <154662261+sharvis8@users.noreply.github.com> Date: Mon, 1 Jan 2024 21:00:10 +0530 Subject: [PATCH 14/18] Added Jenkinsfile --- Jenkinsfile | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Jenkinsfile b/Jenkinsfile index 72ceb8a..555ca48 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -41,5 +41,11 @@ pipeline { } } + stage('KubernetesDeployment') { + steps { + sh 'kubectl create -f Deployment.yaml' + } + } + } } \ No newline at end of file From 473a1a40e7ee10d07583460e2de38e1042a47cd7 Mon Sep 17 00:00:00 2001 From: vishal Date: Tue, 2 Jan 2024 12:09:47 +0530 Subject: [PATCH 15/18] port change --- main.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/main.go b/main.go index e1f69cc..74c3d4f 100644 --- a/main.go +++ b/main.go @@ -38,9 +38,9 @@ func main() { http.HandleFunc("/form", formHandler) http.HandleFunc("/hello", helloHandler) - fmt.Printf("Starting server at port 8080\n") + fmt.Printf("Starting server at port 8090\n") - if err := http.ListenAndServe(":8080", nil); err != nil { + if err := http.ListenAndServe(":8090", nil); err != nil { log.Fatal(err) } } From 68309ccdb9cbb0ebebff4a655d95b574d295a040 Mon Sep 17 00:00:00 2001 From: vishal Date: Thu, 4 Jan 2024 11:53:43 +0530 Subject: [PATCH 16/18] jenkins update --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 555ca48..f03e7b0 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -43,7 +43,7 @@ pipeline { stage('KubernetesDeployment') { steps { - sh 'kubectl create -f Deployment.yaml' + sh 'kubectl create -f Deployment.yaml', kubeconfigId:"kubernetes" } } From 84f3190e655f1a6e5602d79fb565466dd6d2d835 Mon Sep 17 00:00:00 2001 From: sharvis8 <154662261+sharvis8@users.noreply.github.com> Date: Thu, 4 Jan 2024 12:37:36 +0530 Subject: [PATCH 17/18] Update Jenkinsfile --- Jenkinsfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index f03e7b0..a44173c 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -43,9 +43,9 @@ pipeline { stage('KubernetesDeployment') { steps { - sh 'kubectl create -f Deployment.yaml', kubeconfigId:"kubernetes" + script{ kubernetesDeploy('configs: "Deployment.yaml", kubeconfigId:"kubernetes")} } } } -} \ No newline at end of file +} From 5c49d081538760a54a1c70f54f3a79cf7a6f2821 Mon Sep 17 00:00:00 2001 From: sharvis8 <154662261+sharvis8@users.noreply.github.com> Date: Thu, 4 Jan 2024 12:42:20 +0530 Subject: [PATCH 18/18] Update Jenkinsfile --- Jenkinsfile | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index a44173c..3c368bc 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -41,11 +41,6 @@ pipeline { } } - stage('KubernetesDeployment') { - steps { - script{ kubernetesDeploy('configs: "Deployment.yaml", kubeconfigId:"kubernetes")} - } - } - + } }