Skip to content

Commit 1312140

Browse files
authored
chore: update spring boot to v3 (GoogleCloudPlatform#8245)
* chore: update spring boot to v3 * update * remove updates * remove updates * fix tests * update * udpate tests * udpate tests * udpate tests * lint * udpate dockerfiles * fix dockerfiles * debug * update to 3.1.0
1 parent 7d00841 commit 1312140

File tree

28 files changed

+120
-108
lines changed

28 files changed

+120
-108
lines changed

.kokoro/tests/build_cloud_run.sh

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,15 @@ if [ -n "$JIB" ]; then
2121
# Register post-test cleanup.
2222
# Only needed if deploy completed.
2323
function cleanup {
24+
mvn -q -B clean
2425
set -x
25-
gcloud container images delete "${CONTAINER_IMAGE}" --quiet --no-user-output-enabled || true
26+
sha=$(gcloud artifacts docker images describe $CONTAINER_IMAGE --format="value(image_summary.digest)")
27+
gcloud artifacts docker images delete $BASE_IMAGE@$sha --quiet --delete-tags --no-user-output-enabled || true
2628
gcloud run services delete ${SERVICE_NAME} \
2729
--platform=managed \
2830
--region="${REGION:-us-central1}" \
2931
--quiet --no-user-output-enabled
30-
mvn -q -B clean
32+
set +x
3133
}
3234
trap cleanup EXIT
3335

@@ -45,17 +47,16 @@ if [ -n "$JIB" ]; then
4547
export SERVICE_NAME="${SAMPLE_NAME}-${SUFFIX}"
4648
# Remove "/" from the Cloud Run service name
4749
export SERVICE_NAME="${SERVICE_NAME//\//$'-'}"
48-
export CONTAINER_IMAGE="gcr.io/${GOOGLE_CLOUD_PROJECT}/run-${SAMPLE_NAME}:${SAMPLE_VERSION}"
49-
export SPECIAL_BASE_IMAGE="gcr.io/${GOOGLE_CLOUD_PROJECT}/imagemagick"
50+
export BASE_IMAGE="us-central1-docker.pkg.dev/${GOOGLE_CLOUD_PROJECT}/containers/run-${SAMPLE_NAME}"
51+
export CONTAINER_IMAGE="${BASE_IMAGE}:${SAMPLE_VERSION}"
52+
export SPECIAL_BASE_IMAGE="us-central1-docker.pkg.dev/${GOOGLE_CLOUD_PROJECT}/containers/imagemagick"
5053
BASE_IMAGE_SAMPLES=("image-processing" "system-packages")
5154

5255
# Build the service
5356
set -x
54-
5557
mvn -q -B jib:build -Dimage="${CONTAINER_IMAGE}" \
5658
`if [[ "${BASE_IMAGE_SAMPLES[@]}" =~ "${SAMPLE_NAME}" ]]; then echo "-Djib.from.image=${SPECIAL_BASE_IMAGE}"; fi`
5759

58-
5960
export MEMORY_NEEDED=("image-processing" "idp-sql"); # Samples that need more memory
6061

6162
gcloud run deploy "${SERVICE_NAME}" \
@@ -64,8 +65,7 @@ if [ -n "$JIB" ]; then
6465
--platform=managed \
6566
--quiet --no-user-output-enabled \
6667
`if [[ "${MEMORY_NEEDED[@]}" =~ "${SAMPLE_NAME}" ]]; then echo "--memory 512M"; fi` \
67-
`if [ $SAMPLE_NAME = "idp-sql" ]; then echo "--update-env-vars CLOUD_SQL_CREDENTIALS_SECRET=projects/${GOOGLE_CLOUD_PROJECT}/secrets/idp-sql-secret/versions/latest"; fi`
68-
68+
`if [ $SAMPLE_NAME = "idp-sql" ]; then echo "--update-secrets CLOUD_SQL_CREDENTIALS_SECRET=idp-sql-secret:latest"; fi`
6969

7070
set +x
7171

.kokoro/tests/run_test_java.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ if ! [[ ",$JAVA_VERSION," =~ ",$POM_JAVA," ]]; then
3838
exit 0
3939
fi
4040

41-
if [[ ",$JAVA_VERSION," =~ "17" && ( "$file" == *"run/hello-broken"* || "$file" == *"run/filesystem"* || "$file" == *"flexible/java-11/pubsub"* || "$file" == *"flexible/java-11/cloudstorage"*|| "$file" == *"flexible/java-11/datastore"*) ]]; then
41+
if [[ ",$JAVA_VERSION," =~ "17" && ( "$file" == *"run/hello-broken"* || "$file" == *"flexible/java-11/pubsub"* || "$file" == *"flexible/java-11/cloudstorage"*|| "$file" == *"flexible/java-11/datastore"*) ]]; then
4242
echo -e "\n Skipping tests: Sample ($file) tests do not work with Java 17\n"
4343
exit 0
4444
fi
@@ -82,8 +82,8 @@ else
8282
fi
8383

8484
# Build and deploy Cloud Run samples
85-
if [[ "$file" == "run/"* ]]; then
86-
export SAMPLE_NAME=${file#"run/"}
85+
if [[ "$file" == *"run/"* && ("$file" != *"run/filesystem"* && "$file" != *"run/jobs"*) ]]; then
86+
export SAMPLE_NAME=${file#*run/}
8787
# chmod 755 "$SCRIPT_DIR"/build_cloud_run.sh
8888
"$SCRIPT_DIR"/build_cloud_run.sh
8989
EXIT=$?

.kokoro/tests/run_tests.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ if [[ "$SCRIPT_DEBUG" != "true" ]]; then
6666
export DATALABELING_ENDPOINT="test-datalabeling.sandbox.googleapis.com:443"
6767
# For Cloud Run filesystem sample
6868
export FILESTORE_IP_ADDRESS=$(gcloud secrets versions access latest --secret fs-app)
69+
export MNT_DIR=$PWD/run/filesystem
6970

7071
SECRET_FILES=("java-docs-samples-service-account.json" \
7172
"java-aiplatform-samples-secrets.txt" \

appengine-java11/tasks-handler/Dockerfile

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,18 @@
1+
# Copyright 2023 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# https://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
114

2-
# Use the official maven/Java 8 image to create a build artifact.
15+
# Use the official maven image to create a build artifact.
316
# https://hub.docker.com/_/maven
417
FROM maven:3.8-jdk-11 as builder
518

eventarc/audit-storage/Dockerfile

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@
1414

1515
# [START eventarc_audit_storage_dockerfile]
1616

17-
# Use the official maven/Java 8 image to create a build artifact.
17+
# Use the official maven image to create a build artifact.
1818
# https://hub.docker.com/_/maven
19-
FROM maven:3.8-jdk-11 as builder
19+
FROM maven:3-eclipse-temurin-17-alpine as builder
2020

2121
# Copy local code to the container image.
2222
WORKDIR /app
@@ -26,11 +26,9 @@ COPY src ./src
2626
# Build a release artifact.
2727
RUN mvn package -DskipTests
2828

29-
# Use AdoptOpenJDK for base image.
30-
# It's important to use OpenJDK 8u191 or above that has container support enabled.
31-
# https://hub.docker.com/r/adoptopenjdk/openjdk8
29+
# Use Eclipse Temurin for base image.
3230
# https://docs.docker.com/develop/develop-images/multistage-build/#use-multi-stage-builds
33-
FROM adoptopenjdk/openjdk11:alpine-slim
31+
FROM eclipse-temurin:17-jre-alpine
3432

3533
# Copy the jar to the production image from the builder stage.
3634
COPY --from=builder /app/target/audit-storage-*.jar /audit-storage.jar

eventarc/audit-storage/pom.xml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ limitations under the License.
2525
</parent>
2626

2727
<properties>
28-
<maven.compiler.target>11</maven.compiler.target>
29-
<maven.compiler.source>11</maven.compiler.source>
30-
<spring.boot.version>2.7.11</spring.boot.version>
28+
<maven.compiler.target>17</maven.compiler.target>
29+
<maven.compiler.source>17</maven.compiler.source>
30+
<spring.boot.version>3.1.0</spring.boot.version>
3131
</properties>
3232

3333
<dependencyManagement>
@@ -94,7 +94,7 @@ limitations under the License.
9494
<version>3.3.2</version>
9595
<configuration>
9696
<to>
97-
<image>gcr.io/PROJECT_ID/gcs-container</image>
97+
<image>gcr.io/${env.PROJECT_ID}/gcs-container</image>
9898
</to>
9999
</configuration>
100100
</plugin>

eventarc/generic/pom.xml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ limitations under the License.
2525
</parent>
2626

2727
<properties>
28-
<maven.compiler.target>11</maven.compiler.target>
29-
<maven.compiler.source>11</maven.compiler.source>
30-
<spring.boot.version>2.7.11</spring.boot.version>
28+
<maven.compiler.target>17</maven.compiler.target>
29+
<maven.compiler.source>17</maven.compiler.source>
30+
<spring.boot.version>3.1.0</spring.boot.version>
3131
</properties>
3232

3333
<dependencyManagement>
@@ -92,7 +92,7 @@ limitations under the License.
9292
<version>3.3.2</version>
9393
<configuration>
9494
<to>
95-
<image>gcr.io/PROJECT_ID/eventarc-generic</image>
95+
<image>gcr.io/${env.PROJECT_ID}/eventarc-generic</image>
9696
</to>
9797
</configuration>
9898
</plugin>

eventarc/pubsub/Dockerfile

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@
1414

1515
# [START eventarc_pubsub_dockerfile]
1616

17-
# Use the official maven/Java 8 image to create a build artifact.
17+
# Use the official maven image to create a build artifact.
1818
# https://hub.docker.com/_/maven
19-
FROM maven:3.8-jdk-11 as builder
19+
FROM maven:3-eclipse-temurin-17-alpine as builder
2020

2121
# Copy local code to the container image.
2222
WORKDIR /app
@@ -26,11 +26,9 @@ COPY src ./src
2626
# Build a release artifact.
2727
RUN mvn package -DskipTests
2828

29-
# Use AdoptOpenJDK for base image.
30-
# It's important to use OpenJDK 8u191 or above that has container support enabled.
31-
# https://hub.docker.com/r/adoptopenjdk/openjdk8
29+
# Use Eclipse Temurin for base image.
3230
# https://docs.docker.com/develop/develop-images/multistage-build/#use-multi-stage-builds
33-
FROM adoptopenjdk/openjdk11:alpine-slim
31+
FROM eclipse-temurin:17-jre-alpine
3432

3533
# Copy the jar to the production image from the builder stage.
3634
COPY --from=builder /app/target/events-pubsub-*.jar /events-pubsub.jar

eventarc/pubsub/pom.xml

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1111
See the License for the specific language governing permissions and
1212
limitations under the License.
1313
-->
14-
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
14+
<project xmlns="http://maven.apache.org/POM/4.0.0"
15+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
16+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
1517
<modelVersion>4.0.0</modelVersion>
1618
<groupId>com.example.eventarc</groupId>
1719
<artifactId>events-pubsub</artifactId>
@@ -25,9 +27,9 @@ limitations under the License.
2527
</parent>
2628

2729
<properties>
28-
<maven.compiler.target>11</maven.compiler.target>
29-
<maven.compiler.source>11</maven.compiler.source>
30-
<spring.boot.version>2.7.11</spring.boot.version>
30+
<maven.compiler.target>17</maven.compiler.target>
31+
<maven.compiler.source>17</maven.compiler.source>
32+
<spring.boot.version>3.1.0</spring.boot.version>
3133
</properties>
3234

3335
<dependencyManagement>
@@ -58,7 +60,7 @@ limitations under the License.
5860
<dependency>
5961
<groupId>org.apache.commons</groupId>
6062
<artifactId>commons-lang3</artifactId>
61-
</dependency>
63+
</dependency>
6264
<dependency>
6365
<groupId>org.springframework.boot</groupId>
6466
<artifactId>spring-boot-starter-test</artifactId>
@@ -98,7 +100,7 @@ limitations under the License.
98100
<version>3.3.2</version>
99101
<configuration>
100102
<to>
101-
<image>gcr.io/PROJECT_ID/cloudrun-events-pubsub</image>
103+
<image>gcr.io/${env.PROJECT_ID}/cloudrun-events-pubsub</image>
102104
</to>
103105
</configuration>
104106
</plugin>

renovate.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,11 @@
129129
{
130130
"matchPackagePatterns": [ "org.springframework.boot" ],
131131
"matchCurrentVersion": "!/.*[SNAPSHOT | M]/"
132+
},
133+
{
134+
"matchPackagePatterns": [ "org.springframework.boot" ],
135+
"matchPaths": ["appengine-java11/**", "appengine-java8/**", "flexible/*", "flexible/java-11/**", "flexible/java-8/**"],
136+
"allowedVersions": "<3"
132137
}
133138
],
134139
"labels": [

0 commit comments

Comments
 (0)