Skip to content

Commit

Permalink
feat: upgrade to spring boot 3 (#12)
Browse files Browse the repository at this point in the history
* feat: upgrade to spring boot 3

- upgrade other dependencies

* remove import

---------

Co-authored-by: Dylan Decrulle <[email protected]>
  • Loading branch information
davdarras and ddecrulle authored Dec 4, 2023
1 parent 720ff0c commit 7fd6770
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 34 deletions.
17 changes: 9 additions & 8 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,24 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up JDK 11
uses: actions/setup-java@v1
- uses: actions/checkout@v3
- name: Set up JDK 21
uses: actions/setup-java@v3
with:
java-version: 11
distribution: 'temurin'
java-version: '21'
- name: Build with Maven
run: mvn install --file pom.xml
- name: Upload war
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3
with:
name: jar
path: target/*.jar
release:
runs-on: ubuntu-latest
steps:
- name: Checkout current branch
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: Get current version
id: version
run: echo "::set-output name=prop::$(mvn -f pom.xml help:evaluate -Dexpression=project.version -q -DforceStdout)"
Expand All @@ -47,10 +48,10 @@ jobs:
runs-on: ubuntu-latest
environment: ci
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Download build
id: download
uses: actions/download-artifact@v2
uses: actions/download-artifact@v3
with:
name: jar
path: target/
Expand Down
17 changes: 11 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
FROM eclipse-temurin:11-jre-focal
COPY ./target/*.jar /usr/local/app.jar
FROM eclipse-temurin:21-jre-alpine

EXPOSE 8080
RUN adduser knowledge-api
USER knowledge-api
WORKDIR /opt/app/
COPY ./target/*.jar /opt/app/app.jar

CMD ["java","-jar","/usr/local/app.jar"]
# Setup a non-root user context (security)
RUN addgroup -g 1000 knowledge-api-group
RUN adduser -D -s / -u 1000 knowledge-api-user -G knowledge-api-group
RUN chown -R 1000:1000 /opt/app

USER 1000

ENTRYPOINT ["java", "-jar", "/opt/app/app.jar"]
14 changes: 7 additions & 7 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,23 @@

<groupId>fr.insee.knowledge</groupId>
<artifactId>knowledge</artifactId>
<version>0.7.2</version>
<version>0.8.0</version>
<packaging>jar</packaging>
<name>Knowledge-Back-Office</name>
<description>Back-office services for Knowledge</description>

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

<properties>
<java.version>11</java.version>
<java.version>21</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<snakeyaml.version>2.0</snakeyaml.version>
</properties>

<dependencies>
Expand Down Expand Up @@ -51,8 +52,8 @@
<!-- Swagger -->
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-ui</artifactId>
<version>1.6.8</version>
<artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
<version>2.3.0</version>
</dependency>

<!-- MongoDB Drivers -->
Expand All @@ -77,15 +78,14 @@
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.24</version>
<scope>provided</scope>
</dependency>

<!-- JSON dependencies -->
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.13.3</version>
<version>2.15.3</version>
</dependency>

</dependencies>
Expand Down
11 changes: 1 addition & 10 deletions src/main/java/fr/insee/knowledge/StarterApplication.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,16 @@

import fr.insee.knowledge.configuration.PropertiesLogger;
import fr.insee.knowledge.service.InitializerService;
import org.springdoc.core.SpringDocUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.mongo.MongoAutoConfiguration;
import org.springframework.boot.autoconfigure.web.servlet.error.BasicErrorController;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.context.event.ApplicationReadyEvent;
import org.springframework.context.event.EventListener;

import java.io.IOException;


@SpringBootApplication(scanBasePackages = "fr.insee.knowledge", exclude = MongoAutoConfiguration.class)
public class StarterApplication {

static {
SpringDocUtils.getConfig().addHiddenRestControllers(BasicErrorController.class);
}

@Autowired
private InitializerService initializer;

Expand All @@ -35,7 +26,7 @@ public static SpringApplicationBuilder configureApplicationBuilder(SpringApplica


@EventListener(ApplicationReadyEvent.class)
public void doSomethingAfterStartup() throws IOException {
public void doSomethingAfterStartup() {
initializer.createCollections();
}
}
4 changes: 1 addition & 3 deletions src/main/java/fr/insee/knowledge/dao/generic/DAO.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,10 @@
import com.mongodb.client.model.ReplaceOptions;
import com.mongodb.client.model.WriteModel;
import fr.insee.knowledge.domain.GenericIDLabel;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import jakarta.annotation.PostConstruct;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.GenericTypeResolver;

import javax.annotation.PostConstruct;
import java.util.ArrayList;
import java.util.List;

Expand Down

0 comments on commit 7fd6770

Please sign in to comment.