Skip to content

Latest commit

 

History

History
75 lines (51 loc) · 2.01 KB

File metadata and controls

75 lines (51 loc) · 2.01 KB

Java: Cloud Run - hello-gcs

A Cloud Storage triggered Java Cloud Run template.

Test locally

Compile:

mvn compile

Run:

mvn spring-boot:run

2023-02-27 13:33:19.404  INFO 50222 --- [           main] o.s.b.web.embedded.netty.NettyWebServer  : Netty started on port 8080
2023-02-27 13:33:19.411  INFO 50222 --- [           main] run.Application                          : Started Application in 1.172 seconds (JVM running for 1.407)

Inside the scripts folder, run test_local.sh to test locally:

./test_local.sh

< HTTP/1.1 200 OK
< content-length: 0

You should see the following in the service logs:

...
2023-02-27 13:34:01.789  INFO 50222 --- [ctor-http-nio-2] run.Application                          : Id: 123451234512345
2023-02-27 13:34:01.789  INFO 50222 --- [ctor-http-nio-2] run.Application                          : Source: //storage.googleapis.com/projects/_/buckets/MY-BUCKET-NAME
2023-02-27 13:34:01.789  INFO 50222 --- [ctor-http-nio-2] run.Application                          : Type: google.cloud.storage.object.v1.finalized
2023-02-27 13:34:01.864  INFO 50222 --- [ctor-http-nio-2] run.Application                          : Name: MY_FILE.txt
2023-02-27 13:34:01.864  INFO 50222 --- [ctor-http-nio-2] run.Application                          : Bucket: MY_BUCKET
2023-02-27 13:34:01.864  INFO 50222 --- [ctor-http-nio-2] run.Application                          : Size: 352
2023-02-27 13:34:01.864  INFO 50222 --- [ctor-http-nio-2] run.Application                          : Content type: text/plain

Before deploying to Google Cloud

Run setup.sh to enable required services:

./setup.sh

Deploy to Google Cloud

Run deploy.sh to deploy to Google Cloud:

./deploy.sh

Test in Google Cloud

Run test_cloud.sh to test the service in Google Cloud:

./test_cloud.sh

Cleanup

When you're done, you can cleanup created resources:

./cleanup.sh