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
22 changes: 22 additions & 0 deletions .github/pr.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
# This workflow will execute on pull request to dev branch

name: pr-workflow

on:
pull_request:
branches:
- dev

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: get the code
uses: actions/checkout@v6
- name: compile the code
run: mvn compile
- name: test the code
run: mvn test
- name: create the package
run: mvn package
37 changes: 37 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: My First Pipeline

on:
push:

jobs:
build:
runs-on: ubuntu-latest

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

name: Java CI Pipeline

on:
push:
branches: [ main ]

jobs:
build:
runs-on: ubuntu-latest

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

- name: Setup Java
uses: actions/setup-java@v3
with:
java-version: '17'

- name: Build with Maven
run: mvn clean package

- name: Build Docker Image
run: docker build -t petclinic-app .
37 changes: 37 additions & 0 deletions .github/workflows/sonar.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: SonarQube
on:
push:
branches:
- main
pull_request:
types: [opened, synchronize, reopened]
workflows_dispath:
jobs:
build:
name: Build and analyze
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: 17
distribution: 'zulu' # Alternative distribution options are available.
- name: Cache SonarQube packages
uses: actions/cache@v4
with:
path: ~/.sonar/cache
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar
- name: Cache Maven packages
uses: actions/cache@v4
with:
path: ~/.m2
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-m2
- name: Build and analyze
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: mvn -B verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar -Dsonar.projectKey=rizwangourysk_spring-petclinic-dockerdec25
6 changes: 6 additions & 0 deletions Dockerfile.dockerimage
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
FROM maven:3.9.6-eclipse-temurin-17
WORKDIR /build
COPY . .
RUN mvn clean package -DskipTests
EXPOSE 8080
CMD ["java", "-jar", "/build/target/*.jar"]
13 changes: 13 additions & 0 deletions Dockerfile.multistage
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# -------- Build Stage --------
FROM maven:3.9.6-eclipse-temurin-17 AS build
WORKDIR /build
COPY . .
RUN mvn clean package -DskipTests

# -------- Runtime Stage --------
FROM eclipse-temurin:17-jre
WORKDIR /app
COPY --from=build /build/target/*.jar app.jar
EXPOSE 8080
CMD ["java", "-jar", "app.jar"]

29 changes: 29 additions & 0 deletions Dockerfile.singlestage
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# 1. Base image
FROM ubuntu:22.04

# 2. Avoid interactive prompts
ENV DEBIAN_FRONTEND=noninteractive

# 3. Install system packages
RUN apt update && apt install -y \
git \
openjdk-17-jdk \
maven \
&& apt clean \
&& rm -rf /var/lib/apt/lists/*

# 4. Set working directory
WORKDIR /app

# 5. Copy project files
COPY . /app

# 6. Build the project (creates target/*.jar)
RUN mvn clean package -DskipTests

# 7. Expose application port
EXPOSE 8080

# 8. Run the JAR file
CMD ["sh", "-c", "java -jar target/*.jar"]

4 changes: 4 additions & 0 deletions dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
FROM eclipse-temurin:17-jdk
WORKDIR /app
COPY target/*.jar app.jar
ENTRYPOINT ["java","-jar","app.jar"]
1 change: 1 addition & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
<maven-checkstyle.version>3.6.0</maven-checkstyle.version>
<nohttp-checkstyle.version>0.0.11</nohttp-checkstyle.version>
<spring-format.version>0.0.47</spring-format.version>
<sonar.organization>rizwangourysk</sonar.organization>
</properties>

<licenses>
Expand Down
1 change: 1 addition & 0 deletions spring-petclinic
Submodule spring-petclinic added at edf4db
1 change: 1 addition & 0 deletions test.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
test change