Skip to content

Commit

Permalink
Upgraded dependencies, replaced deprecated code
Browse files Browse the repository at this point in the history
  • Loading branch information
zhoozhoo committed Sep 19, 2024
1 parent d24555d commit 33df53e
Show file tree
Hide file tree
Showing 15 changed files with 87 additions and 524 deletions.
34 changes: 4 additions & 30 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,31 +1,5 @@
FROM openjdk:11-jre as builder
WORKDIR /application
COPY maven/*.jar application.jar
RUN java -Djarmode=layertools -jar application.jar extract

# Download dockerize and cache that layer
ARG DOCKERIZE_VERSION
ADD https://github.com/jwilder/dockerize/releases/download/${DOCKERIZE_VERSION}/dockerize-alpine-linux-amd64-${DOCKERIZE_VERSION}.tar.gz ./dockerize.tar.gz
RUN tar xzf dockerize.tar.gz
RUN chmod +x dockerize

FROM adoptopenjdk:16-jre-hotspot

LABEL maintainer="zhoozhoo@yahoo.com"

WORKDIR /application

# Dockerize
COPY --from=builder application/dockerize ./

ARG EXPOSED_PORT
EXPOSE ${EXPOSED_PORT}

FROM eclipse-temurin:21-jre-alpine
LABEL Author="zhoozhoo@yahoo.com"
ENV SPRING_PROFILES_ACTIVE docker

COPY --from=builder application/dependencies/ ./
COPY --from=builder application/spring-boot-loader/ ./
COPY --from=builder application/snapshot-dependencies/ ./
COPY --from=builder application/application/ ./

ENTRYPOINT ["java", "org.springframework.boot.loader.JarLauncher"]
COPY maven/*.jar application.jar
ENTRYPOINT ["java","-jar","/application.jar"]
2 changes: 1 addition & 1 deletion docker/keycloak/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM jboss/keycloak:latest
FROM quay.io/keycloak/keycloak:latest
COPY spring-cloud-gateway-realm.json /tmp
ENV KEYCLOAK_USER=user
ENV KEYCLOAK_PASSWORD=password
Expand Down
60 changes: 14 additions & 46 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.3.3</version>
<version>3.3.4</version>
</parent>

<groupId>ca.zhoozhoo.spring.cloud</groupId>
Expand All @@ -29,14 +29,13 @@

<properties>
<java.version>21</java.version>
<spring-boot.version>3.3.3</spring-boot.version>
<spring-boot.version>3.3.4</spring-boot.version>
<spring-cloud.version>2023.0.3</spring-cloud.version>
<spring-boot-admin.version>3.3.3</spring-boot-admin.version>
<jolokia-core.version>1.7.2</jolokia-core.version>
<keycloak.version>13.0.1</keycloak.version>
<keycloak.version>25.0.5</keycloak.version>
<docker.image.prefix>zhoozhoo</docker.image.prefix>
<docker.image.dockerize.version>v0.8.0</docker.image.dockerize.version>
<kubernetes-maven-plugin.version>1.17.0</kubernetes-maven-plugin.version>
<jkube.version>1.17.0</jkube.version>
</properties>

<dependencyManagement>
Expand All @@ -61,69 +60,38 @@
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<fork>true</fork>
<layers>
<enabled>true</enabled>
</layers>
</configuration>
<executions>
<execution>
<goals>
<goal>build-info</goal>
<goal>build-image-no-fork</goal>
</goals>
<configuration>
<additionalProperties>
<encoding.source>${project.build.sourceEncoding}</encoding.source>
<encoding.reporting>${project.reporting.outputEncoding}</encoding.reporting>
<encoding.source>UTF-8</encoding.source>
<encoding.reporting>UTF-8</encoding.reporting>
<java.version>${java.version}</java.version>
</additionalProperties>
<image>
<name>
${docker.image.prefix}/${project.artifactId}:${project.version}</name>
<runImage>eclipse-temurin:${java.version}-jre-alpine</runImage>
</image>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>

<profiles>
<profiles>
<profile>
<id>docker</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.eclipse.jkube</groupId>
<artifactId>kubernetes-maven-plugin</artifactId>
<version>${kubernetes-maven-plugin.version}</version>
<configuration>
<images>
<image>
<alias>${project.artifactId}</alias>
<name>${docker.image.prefix}/${project.artifactId}:${project.version}</name>
<build>
<contextDir>${project.basedir}/../docker</contextDir>
<args>
<DOCKERIZE_VERSION>${docker.image.dockerize.version}</DOCKERIZE_VERSION>
<EXPOSED_PORT>${docker.image.exposed.port}</EXPOSED_PORT>
</args>
</build>
</image>
</images>
</configuration>
<executions>
<execution>
<goals>
<goal>build</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</pluginManagement>
</build>
</profile>
</profiles>
</project>
</project>
Original file line number Diff line number Diff line change
@@ -1,38 +1,27 @@
package ca.zhoozhoo.springcloud.api.config;

import static org.springframework.security.config.Customizer.withDefaults;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile;
import org.springframework.security.config.annotation.method.configuration.EnableReactiveMethodSecurity;
import org.springframework.security.config.annotation.web.reactive.EnableWebFluxSecurity;
import org.springframework.security.config.web.server.ServerHttpSecurity;
import org.springframework.security.oauth2.client.oidc.web.server.logout.OidcClientInitiatedServerLogoutSuccessHandler;
import org.springframework.security.oauth2.client.registration.ReactiveClientRegistrationRepository;
import org.springframework.security.web.server.SecurityWebFilterChain;
import org.springframework.security.web.server.header.XFrameOptionsServerHttpHeadersWriter.Mode;

@Configuration
@EnableReactiveMethodSecurity
@EnableWebFluxSecurity
@Profile({"docker", "kubernetes"})
@EnableReactiveMethodSecurity
public class SecurityConfig {

@Bean
public SecurityWebFilterChain springSecurityFilterChain(ServerHttpSecurity http,
ReactiveClientRegistrationRepository clientRegistrationRepository) {
// Authenticate through configured OpenID Provider
http.oauth2Login();
// Also logout at the OpenID Connect provider
http.logout(logout -> logout
.logoutSuccessHandler(new OidcClientInitiatedServerLogoutSuccessHandler(clientRegistrationRepository)));
// Allow unauthenticated actuator access
http.authorizeExchange().pathMatchers("/actuator/**").permitAll();
// Require authentication for all requests
http.authorizeExchange().anyExchange().authenticated();
// Allow showing /home within a frame
http.headers().frameOptions().mode(Mode.SAMEORIGIN);
// Disable CSRF in the gateway to prevent conflicts with proxied service CSRF
http.csrf().disable();
public SecurityWebFilterChain springSecurityFilterChain(ServerHttpSecurity http) {
http.authorizeExchange(exchanges -> exchanges
.anyExchange()
.authenticated())
.oauth2Login(withDefaults())
.oauth2ResourceServer((resourceServer) -> resourceServer
.jwt(withDefaults()));

return http.build();
}
Expand Down
7 changes: 1 addition & 6 deletions spring-cloud-auth-server/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,6 @@
</dependency>

<!-- KeyCloak -->
<dependency>
<groupId>org.keycloak</groupId>
<artifactId>keycloak-spring-boot-starter</artifactId>
<version>${keycloak.version}</version>
</dependency>
<dependency>
<groupId>org.keycloak</groupId>
<artifactId>keycloak-admin-client</artifactId>
Expand All @@ -59,7 +54,7 @@
<alias>${project.artifactId}</alias>
<name>${docker.image.prefix}/${project.artifactId}:${project.version}</name>
<build combine.self="override">
<from>jboss/keycloak:${keycloak.version}</from>
<from>quay.io/keycloak/keycloak:${keycloak.version}</from>
<env>
<KEYCLOAK_USER>admin</KEYCLOAK_USER>
<KEYCLOAK_PASSWORD>admin</KEYCLOAK_PASSWORD>
Expand Down
35 changes: 12 additions & 23 deletions spring-cloud-config-server/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,6 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>

<!-- Spring Cloud -->
<dependency>
Expand All @@ -39,7 +34,18 @@
<artifactId>spring-cloud-starter-bootstrap</artifactId>
</dependency>

<!-- Third-party librairies -->
<dependency>
<groupId>org.jolokia</groupId>
<artifactId>jolokia-core</artifactId>
</dependency>

<!-- Testing -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
Expand All @@ -51,21 +57,4 @@
<scope>test</scope>
</dependency>
</dependencies>

<profiles>
<profile>
<id>docker</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.eclipse.jkube</groupId>
<artifactId>kubernetes-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
</project>
17 changes: 0 additions & 17 deletions spring-cloud-discovery-server/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -45,21 +45,4 @@
<artifactId>spring-retry</artifactId>
</dependency>
</dependencies>

<profiles>
<profile>
<id>docker</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.eclipse.jkube</groupId>
<artifactId>kubernetes-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
17 changes: 0 additions & 17 deletions spring-cloud-guest-service/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -96,21 +96,4 @@
<scope>test</scope>
</dependency>
</dependencies>

<profiles>
<profile>
<id>docker</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.eclipse.jkube</groupId>
<artifactId>kubernetes-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
Loading

0 comments on commit 33df53e

Please sign in to comment.