Skip to content

Jenkins #1944

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 8 commits into
base: main
Choose a base branch
from
Open

Jenkins #1944

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
2 changes: 0 additions & 2 deletions .github/dco.yml

This file was deleted.

33 changes: 33 additions & 0 deletions .github/workflows/ci-cd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: CI/CD - Docker Build & Push

on:
push:
branches:
- main # or change to your main branch name
pull_request:
branches:
- main

jobs:
build-and-push:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: vinayasuresh
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: vinayasuresh/spring-petclinic:latest
31 changes: 0 additions & 31 deletions .github/workflows/deploy-and-test-cluster.yml

This file was deleted.

31 changes: 0 additions & 31 deletions .github/workflows/gradle-build.yml

This file was deleted.

29 changes: 0 additions & 29 deletions .github/workflows/maven-build.yml

This file was deleted.

4 changes: 4 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
FROM anapsix/alpine-java
LABEL maintainer="[email protected]"
COPY /target/spring-petclinic-1.5.1.jar /home/spring-petclinic-1.5.1.jar
CMD ["java","-jar","/home/spring-petclinic-1.5.1.jar"]
43 changes: 43 additions & 0 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
pipeline {
agent {
docker {
image 'maven:3.9.6-eclipse-temurin-17'
}
}

environment {
IMAGE_NAME = "local-app:latest"
CONTAINER_NAME = "local-app-container"
}

stages {
stage('Build App') {
steps {
sh 'mvn clean package -DskipTests'
}
}

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

stage('Stop Existing Container') {
steps {
sh '''
docker stop $CONTAINER_NAME || true
docker rm $CONTAINER_NAME || true
'''
}
}

stage('Run Docker Container') {
steps {
sh '''
docker run -d --name $CONTAINER_NAME -p 8080:8080 $IMAGE_NAME
'''
}
}
}
}