Skip to content
Merged
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
31 changes: 22 additions & 9 deletions .github/workflows/docker-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,38 +11,51 @@ jobs:
runs-on: ubuntu-latest

steps:

# 1. Get the source code
- name: Checkout Code
uses: actions/checkout@v4

# 2. Setup Java 21 with Maven Caching
- name: Set up JDK 21
uses: actions/setup-java@v4
with:
java-version: '21'
distribution: 'temurin'
cache: maven

# 3. Run Tests & Coverage Gate
- name: Run Unit Tests
run: mvn test

run: mvn clean test

# 4. Generate Coverage Summary for GitHub UI
- name: Add Coverage Summary to Action
uses: irongut/CodeCoverageSummary@v1.3.0
with:
filename: target/site/jacoco/jacoco.xml
badge: true
format: markdown
output: both

- name: Write Summary to GitHub Step
run: cat code-coverage-results.md >> $GITHUB_STEP_SUMMARY

# 5. Prepare Docker
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}


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


# 6. Build and Push (Only if tests passed)
- name: Build and Push Image
uses: docker/build-push-action@v5
with:
context: .
file: ./Dockerfile
push: true

context: .
file: ./Dockerfile
push: true
tags: |
${{ secrets.DOCKERHUB_USERNAME }}/docker-test:latest
${{ secrets.DOCKERHUB_USERNAME }}/docker-test:${{ github.sha }}
27 changes: 0 additions & 27 deletions .github/workflows/main.yml

This file was deleted.

1 change: 0 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ services:
volumes:
- /var/run/docker.sock:/var/run/docker.sock
environment:
# If your Docker Hub repo is private, you need these:
- REPO_USER=${DOCKERHUB_USERNAME}
- REPO_PASS=${DOCKERHUB_TOKEN}
command: --interval 30 --cleanup # Check for updates every 30 seconds
1 change: 0 additions & 1 deletion dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,4 @@ USER appuser
COPY --from=build /app/ci-cd-docker-github/target/*.jar app.jar

# Standard Java 25 execution
# Optional: Added flags for better container memory management
ENTRYPOINT ["java", "-XX:+UseContainerSupport", "-Xmx512m", "-jar", "app.jar"]
40 changes: 40 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,46 @@
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.12</version>
<executions>
<execution>
<id>prepare-agent</id>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>report</id>
<phase>test</phase>
<goals>
<goal>report</goal>
</goals>
</execution>
<execution>
<id>check-coverage</id>
<goals>
<goal>check</goal>
</goals>
<configuration>
<rules>
<rule>
<element>BUNDLE</element>
<limits>
<limit>
<counter>LINE</counter>
<value>COVEREDRATIO</value>
<minimum>0.80</minimum>
</limit>
</limits>
</rule>
</rules>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/dhurba/docker/Application.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

@SpringBootApplication
public class Application {
static void main(String[] args) {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ void fetchAll() {
when(modelRepo.findAll()).thenReturn(Collections.singletonList(createModel()));
List<ModelDto> modelDtos = dummyService.fetchAll();
verify(modelRepo).findAll();
assert modelDtos.size() == 9;
assert modelDtos.size() == 1;
}

private Model createModel() {
Expand Down