Skip to content

Commit

Permalink
Feature/fg 128 (#300)
Browse files Browse the repository at this point in the history
* updated project to java 21, edited relevant packages and updated dockerfile

* backup pom from previous project

* change java version in sonarcloud to java 21

* added user to docker file and changed java verson on workflow

* changed docker-compose to docker compose because of updated syntax

* changed import order in globalexeptionhandler to lexicographical

* added system specification to linux on create user in dockerfile
  • Loading branch information
Gissebass authored Oct 26, 2024
1 parent 96a8c27 commit 8485d3f
Show file tree
Hide file tree
Showing 26 changed files with 430 additions and 87 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci-cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
- name: Build docker stack
run: |
docker network create traefik
docker-compose -f docker-compose.yml -f docker-compose.test.yml up run-tests
docker compose -f docker-compose.yml -f docker-compose.test.yml up run-tests
# This workflow contains a single job called "build"
build-and-deploy:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
- name: Build docker stack
run: |
docker network create traefik
docker-compose -f docker-compose.yml -f docker-compose.test.yml up run-tests
docker compose -f docker-compose.yml -f docker-compose.test.yml up run-tests
lint:
runs-on: ubuntu-latest
steps:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/master_hilfling-backend.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
- name: Set up Java version
uses: actions/setup-java@v1
with:
java-version: '11'
java-version: '21'

- name: Build with Maven
run: mvn clean install
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
- name: Set up Java version
uses: actions/setup-java@v1
with:
java-version: "11"
java-version: "21"

- name: Build with Maven
run: mvn clean install
Expand Down
12 changes: 7 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# Stage 1: Build the project

FROM maven:3.6.3-jdk-11-slim AS MAVEN_BUILD
FROM openjdk:21-slim AS MAVEN_BUILD

# Install Maven
RUN apt-get update && apt-get install -y maven

# Tomcat creates a working dir at /tmp by default. Might be optional
VOLUME /tmp
Expand All @@ -11,12 +14,11 @@ RUN mvn package -DskipTests=true
RUN ls /build/target

# Stage 2: prepare launch environment
FROM alpine:3.18.4
RUN apk --no-cache add openjdk11
FROM openjdk:21-slim
# Running with user privileges helts to migate some risks: This is currently disabled bacause
# The application did not have enough privileges to save images to disk
#RUN addgroup -S spring && adduser -S spring -G spring
#USER spring:spring
RUN addgroup --system spring && adduser --system --ingroup spring spring
USER spring:spring
WORKDIR /app
COPY --from=MAVEN_BUILD /build/target/*.jar /app/
RUN ls /app/
Expand Down
106 changes: 50 additions & 56 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.6.3</version>
<version>3.2.0</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>no.fg.hilflingbackend</groupId>
Expand All @@ -15,15 +15,19 @@
<description>Photo API service for hilfling</description>

<properties>
<java.version>11</java.version>
<kotlin.version>1.6.10</kotlin.version>
<kotlin.compiler.apiVersion>1.4</kotlin.compiler.apiVersion>
<jacoco.version>0.8.3</jacoco.version>
<java.version>21</java.version>
<kotlin.version>1.9.24</kotlin.version>
<kotlin.compiler.apiVersion>1.9</kotlin.compiler.apiVersion>
<jacoco.version>0.8.13</jacoco.version>
<kotlinx-coroutines.version>1.4.2-native-mt</kotlinx-coroutines.version>
<sonar.java.coveragePlugin>jacoco</sonar.java.coveragePlugin>
<sonar.dynamicAnalysis>reuseReports</sonar.dynamicAnalysis>
<sonar.jacoco.reportPath>${project.basedir}/../target/jacoco.exec</sonar.jacoco.reportPath>
<sonar.language>kotlin</sonar.language>
<flyway.version>9.22.1</flyway.version>
<jakarta.version>3.1.0</jakarta.version>
<ktorm.version>3.1.0</ktorm.version>
<springdoc.version>2.6.0</springdoc.version>
</properties>

<dependencies>
Expand All @@ -42,7 +46,7 @@
<dependency>
<groupId>io.projectreactor</groupId>
<artifactId>reactor-core</artifactId>
<version>3.4.14</version>
<version>3.6.10</version>
</dependency>

<!-- Thanks for using https://jar-download.com -->
Expand All @@ -61,32 +65,52 @@
<dependency>
<groupId>org.flywaydb</groupId>
<artifactId>flyway-core</artifactId>
<version>${flyway.version}</version>
</dependency>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-reflect</artifactId>
<version>${kotlin.version}</version>

</dependency>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-stdlib-jdk8</artifactId>
<version>${kotlin.version}</version>
</dependency>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-runtime</artifactId>
<version>1.2.71</version>
<groupId>jakarta.persistence</groupId>
<artifactId>jakarta.persistence-api</artifactId>
<version>${jakarta.version}</version> <!-- Update to the latest version -->
</dependency>
<dependency>
<groupId>jakarta.validation</groupId>
<artifactId>jakarta.validation-api</artifactId>
<version>${jakarta.version}</version>
</dependency>
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-starter-webmvc-api</artifactId>
<version>${springdoc.version}</version>
</dependency>
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
<version>${springdoc.version}</version>
</dependency>



<!-- Database -->
<dependency>
<groupId>me.liuwj.ktorm</groupId>
<artifactId>ktorm-core</artifactId>
<version>3.1.0</version>
<version>${ktorm.version}</version>
</dependency>
<dependency>
<groupId>me.liuwj.ktorm</groupId>
<artifactId>ktorm-support-postgresql</artifactId>
<version>3.1.0</version>
<version>${ktorm.version}</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.module</groupId>
Expand All @@ -95,7 +119,7 @@
<dependency>
<groupId>me.liuwj.ktorm</groupId>
<artifactId>ktorm-jackson</artifactId>
<version>3.1.0</version>
<version>${ktorm.version}</version>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
Expand All @@ -112,19 +136,7 @@
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<!-- Documentation -->
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-ui</artifactId>
<version>1.6.5</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.springdoc/springdoc-openapi-maven-plugin -->
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-maven-plugin</artifactId>
<version>1.3</version>
<type>maven-plugin</type>
</dependency>


<!-- Image scaler -->
<dependency>
Expand All @@ -145,7 +157,7 @@
<dependency>
<groupId>com.azure</groupId>
<artifactId>azure-storage-blob</artifactId>
<version>12.14.3</version>
<version>12.28.0</version>
</dependency>


Expand All @@ -159,25 +171,25 @@
<dependency>
<groupId>org.spekframework.spek2</groupId>
<artifactId>spek-dsl-jvm</artifactId>
<version>2.0.17</version>
<version>2.0.19</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.spekframework.spek2</groupId>
<artifactId>spek-runner-junit5</artifactId>
<version>2.0.17</version>
<version>2.0.19</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-runner</artifactId>
<version>1.8.2</version>
<version>1.11.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-stdlib</artifactId>
<version>1.6.10</version>
<version>2.1.0-Beta1</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
Expand Down Expand Up @@ -216,7 +228,12 @@
<id>central2</id>
<url>https://jcenter.bintray.com</url>
</repository>
<repository>
<id>spring-releases</id>
<url>https://repo.spring.io/release</url>
</repository>
</repositories>

<build>
<sourceDirectory>${project.basedir}/src/main/kotlin</sourceDirectory>
<testSourceDirectory>${project.basedir}/src/test/kotlin</testSourceDirectory>
Expand All @@ -228,6 +245,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.13.0</version>
<executions>
<execution>
<id>compile</id>
Expand All @@ -248,7 +266,7 @@
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.2</version>
<version>3.3.1</version>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
Expand Down Expand Up @@ -291,17 +309,12 @@
<artifactId>kotlin-maven-noarg</artifactId>
<version>${kotlin.version}</version>
</dependency>
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-ui</artifactId>
<version>1.6.5</version>
</dependency>
</dependencies>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>2.6.3</version>
<version>3.3.4</version>
<configuration>
<jvmArguments>-Dspring.application.admin.enabled=true</jvmArguments>
</configuration>
Expand All @@ -320,25 +333,6 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-maven-plugin</artifactId>
<version>0.2</version>
<executions>
<execution>
<id>integration-test</id>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<apiDocsUrl>http://localhost:8000/api-docs</apiDocsUrl>
<outputFileName>openapi.json</outputFileName>
<outputDir>${project.build.directory}</outputDir>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>

</project>
Loading

0 comments on commit 8485d3f

Please sign in to comment.