Skip to content

Commit

Permalink
Upgrade to java 18 and fix dependencies and api changes
Browse files Browse the repository at this point in the history
  • Loading branch information
chengruizhe committed Jan 27, 2023
1 parent 5fa21d8 commit 3fc8499
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 47 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM java:openjdk-8-alpine
FROM openjdk:18-alpine

WORKDIR /usr/src/app
COPY ./target/*.jar ./app.jar
Expand Down
23 changes: 4 additions & 19 deletions docker/carts/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,24 +1,9 @@
FROM weaveworksdemos/msd-java:jre-latest
FROM openjdk:18-jdk-alpine

WORKDIR /usr/src/app
COPY *.jar ./app.jar

RUN chown -R ${SERVICE_USER}:${SERVICE_GROUP} ./app.jar
RUN chown -R root:root ./app.jar

USER ${SERVICE_USER}

ARG BUILD_DATE
ARG BUILD_VERSION
ARG COMMIT

LABEL org.label-schema.vendor="Weaveworks" \
org.label-schema.build-date="${BUILD_DATE}" \
org.label-schema.version="${BUILD_VERSION}" \
org.label-schema.name="Socks Shop: Cart" \
org.label-schema.description="REST API for Cart service" \
org.label-schema.url="https://github.com/microservices-demo/carts" \
org.label-schema.vcs-url="github.com:microservices-demo/carts.git" \
org.label-schema.vcs-ref="${COMMIT}" \
org.label-schema.schema-version="1.0"

ENTRYPOINT ["/usr/local/bin/java.sh","-jar","./app.jar", "--port=80"]
USER root
ENTRYPOINT ["java","-jar","./app.jar", "--port=8080"]
27 changes: 13 additions & 14 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.4.0</version>
<version>3.0.2</version>
<relativePath/>
</parent>

Expand All @@ -36,23 +36,18 @@
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
<version>2.6.7</version>
<version>3.0.2</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>5.3.19</version>
<version>6.0.4</version>
</dependency>
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
<version>2.0.1.Final</version>
</dependency>
<dependency>
<groupId>org.mongodb</groupId>
<artifactId>mongo-java-driver</artifactId>
<version>3.12.10</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
Expand All @@ -62,12 +57,11 @@
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-rest</artifactId>
<version>2.6.6</version>
<version>3.0.2</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-mongodb</artifactId>
<version>2.6.6</version>
</dependency>
<dependency>
<groupId>io.prometheus</groupId>
Expand Down Expand Up @@ -106,6 +100,11 @@
<version>0.8.4</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>4.0.1</version>
</dependency>
</dependencies>

<build>
Expand All @@ -114,12 +113,12 @@
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>1.5.22.RELEASE</version>
<version>3.0.2</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.19.1</version>
<version>3.0.0-M8</version>
<configuration>
<includes>
<include>**/Unit*.java</include>
Expand All @@ -132,7 +131,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.18.1</version>
<version>3.0.0-M8</version>
<configuration>
<includes>
<include>**/IT*.java</include>
Expand All @@ -153,7 +152,7 @@
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.7.6.201602180812</version>
<version>0.8.8</version>
<executions>
<execution>
<id>prepare-agent</id>
Expand Down
4 changes: 3 additions & 1 deletion scripts/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ else
fi
CODE_DIR=$(cd $SCRIPT_DIR/..; pwd)
echo $CODE_DIR
$DOCKER_CMD run --rm -v $HOME/.m2:/root/.m2 -v $CODE_DIR:/usr/src/mymaven -w /usr/src/mymaven maven:3.8.5-openjdk-18 mvn -q -DskipTests package
$DOCKER_CMD run --rm -v $HOME/.m2:/root/.m2 -v $CODE_DIR:/usr/src/mymaven -w /usr/src/mymaven maven:3.8.5-openjdk-18 mvn -q -e -DskipTests package

echo $(ls -lt $CODE_DIR/target/*.jar)

cp $CODE_DIR/target/*.jar $CODE_DIR/docker/carts

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,7 @@
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import com.mongodb.MongoClientOptions;

@Configuration
@AutoConfigureBefore(MongoAutoConfiguration.class)
public class MongoConfiguration {

@Bean
public MongoClientOptions optionsProvider() {
MongoClientOptions.Builder optionsBuilder = new MongoClientOptions.Builder();
optionsBuilder.serverSelectionTimeout(10000);
MongoClientOptions options = optionsBuilder.build();
return options;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
import org.springframework.web.servlet.mvc.condition.PatternsRequestCondition;
import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import java.util.HashSet;
import java.util.Set;

Expand Down

0 comments on commit 3fc8499

Please sign in to comment.