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
33 changes: 20 additions & 13 deletions salary/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,18 +1,25 @@
FROM maven:latest as builder
MAINTAINER Opstree Solutions
WORKDIR /java/
COPY pom.xml /java/
COPY src /java/src/
# Stage 1: Build the application using Maven and Java 17
FROM maven:3.8.8-eclipse-temurin-17 AS builder
LABEL maintainer="Opstree Solutions"

WORKDIR /java
COPY pom.xml .
COPY src ./src

RUN mvn clean package

FROM alpine:latest
MAINTAINER Opstree Solutions
USER root
RUN apk update && \
apk add openjdk17
# Stage 2: Run the application with a minimal runtime image
FROM eclipse-temurin:17-jdk-alpine
LABEL maintainer="Opstree Solutions"

WORKDIR /app

COPY --from=builder /java/target/salary-0.3.0-RELEASE.jar /app/salary.jar
COPY ./config.yaml /root/config/config.yaml
ENV CONFIG_FILE "/root/config/config.yaml"
COPY ./config.yaml /app/config/config.yaml
ENV CONFIG_FILE=/app/config/config.yaml

# Expose the app port
EXPOSE 8080
ENTRYPOINT ["/usr/bin/java", "-jar", "/app/salary.jar"]

# Run the Spring Boot app
ENTRYPOINT ["java", "-jar", "/app/salary.jar"]
58 changes: 39 additions & 19 deletions salary/pom.xml
Original file line number Diff line number Diff line change
@@ -1,34 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">

<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.7.4</version>
<relativePath/> <!-- lookup parent from repository -->
<relativePath/>
</parent>

<groupId>com.opstree.microservice</groupId>
<artifactId>salary</artifactId>
<version>0.3.0-RELEASE</version>
<name>salary</name>
<description>Salary Microservice</description>
<reporting>
<plugins>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<reportSets>
<reportSet>
<reports>
<!-- select non-aggregate reports -->
<report>report</report>
</reports>
</reportSet>
</reportSets>
</plugin>
</plugins>
</reporting>

<properties>
<java.version>17</java.version>
</properties>

<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
Expand Down Expand Up @@ -78,15 +71,42 @@

<build>
<plugins>
<!-- Spring Boot Plugin for fat JAR -->
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>

<!-- Java compiler plugin with version -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>17</source>
<target>17</target>
</configuration>
</plugin>

<!-- JaCoCo for code coverage -->
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.6</version>
<version>0.8.8</version>
<executions>
<execution>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>report</id>
<phase>test</phase>
<goals>
<goal>report</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
Expand Down