diff --git a/docker/carts/Dockerfile b/docker/carts/Dockerfile index 3938aff44..d8631177b 100644 --- a/docker/carts/Dockerfile +++ b/docker/carts/Dockerfile @@ -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"] diff --git a/pom.xml b/pom.xml index 3c0868eb5..92d889404 100644 --- a/pom.xml +++ b/pom.xml @@ -14,29 +14,55 @@ org.springframework.boot spring-boot-starter-parent - 2.0.4.RELEASE + 3.0.2 + UTF-8 - 1.8 + 18 0.0.21 + + org.hibernate.validator + hibernate-validator + + + com.h2database + h2 + + + org.springframework.boot + spring-boot-starter-data-jpa + 3.0.2 + + + org.springframework + spring-core + 6.0.4 + + + javax.validation + validation-api + 2.0.1.Final + + + junit + junit + 4.13.2 + test + org.springframework.boot spring-boot-starter-data-rest + 3.0.2 org.springframework.boot spring-boot-starter-data-mongodb - - org.springframework.cloud - spring-cloud-starter-zipkin - 1.1.0.RELEASE - io.prometheus simpleclient_spring_boot @@ -55,6 +81,7 @@ org.springframework.data spring-data-rest-hal-browser + 3.3.9.RELEASE org.springframework.boot @@ -73,6 +100,11 @@ 0.8.4 test + + javax.servlet + javax.servlet-api + 4.0.1 + @@ -81,11 +113,12 @@ org.springframework.boot spring-boot-maven-plugin + 3.0.2 org.apache.maven.plugins maven-surefire-plugin - 2.19.1 + 3.0.0-M8 **/Unit*.java @@ -98,7 +131,7 @@ org.apache.maven.plugins maven-failsafe-plugin - 2.18.1 + 3.0.0-M8 **/IT*.java @@ -119,7 +152,7 @@ org.jacoco jacoco-maven-plugin - 0.8.4 + 0.8.8 prepare-agent diff --git a/scripts/build.sh b/scripts/build.sh index 7f6271768..ee014c417 100755 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -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.6-jdk-11 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 diff --git a/src/main/java/works/weave/socks/cart/CartApplication.java b/src/main/java/works/weave/socks/cart/CartApplication.java index 51d9a8d45..edef51ae7 100644 --- a/src/main/java/works/weave/socks/cart/CartApplication.java +++ b/src/main/java/works/weave/socks/cart/CartApplication.java @@ -1,11 +1,9 @@ package works.weave.socks.cart; -import io.prometheus.client.spring.boot.EnablePrometheusEndpoint; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; @SpringBootApplication -@EnablePrometheusEndpoint public class CartApplication { public static void main(String[] args) { SpringApplication.run(CartApplication.class, args); diff --git a/src/main/java/works/weave/socks/cart/configuration/MongoConfiguration.java b/src/main/java/works/weave/socks/cart/configuration/MongoConfiguration.java index 89688859d..9dd41bbe8 100644 --- a/src/main/java/works/weave/socks/cart/configuration/MongoConfiguration.java +++ b/src/main/java/works/weave/socks/cart/configuration/MongoConfiguration.java @@ -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; - } } diff --git a/src/main/java/works/weave/socks/cart/middleware/HTTPMonitoringInterceptor.java b/src/main/java/works/weave/socks/cart/middleware/HTTPMonitoringInterceptor.java index 728b3423f..105c8e8ad 100644 --- a/src/main/java/works/weave/socks/cart/middleware/HTTPMonitoringInterceptor.java +++ b/src/main/java/works/weave/socks/cart/middleware/HTTPMonitoringInterceptor.java @@ -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;