Reputation: 3898
I have a Spring Boot Application which we deploy as a lambda function on AWS. Is there a similar way to deploy a Sprint Boot Application as GCP cloud function?
Excuse me if the question is naive but I couldn't find any straight forward way from the GCP documentation.
Upvotes: 5
Views: 5274
Reputation: 1272
To deploy my Spring Boot application on Google App Engine, I did the following:
Added the following maven plugin:
<plugin>
<groupId>com.google.cloud.tools</groupId>
<artifactId>appengine-maven-plugin</artifactId>
<version>2.2.0</version>
<configuration>
<version>1</version>
<projectId>levelupfin-1fe89</projectId>
</configuration>
</plugin>
Created the following file: src/main/appengine/app.yaml
runtime: java11
instance_class: F1
Ran the following commands:
# To deploy to app engine
mvn appengine:deploy
# To see your app
gcloud app browse
I got much of this info from the following code lab.
Upvotes: 0
Reputation: 76018
I recommend you to have a look to Cloud Run. If your Spring Boot app already start in standalone (with spring boot starter), the Cloud Run packaging is easy. You can find example in my repo, or through this article (and others)
Upvotes: 4
Reputation: 2874
Most places I've worked will build/compile a fat-jar of their spring-boot application, drop it in to a docker container (create a Dockerfile and then build the image), then deploy the container 1 or many times over using the image as a basis (and have a load balancer in front of it for the many instances set up).
Today we have kubernetes/ansible, etc. Pick your poison or go without.. it's what will work best for you, but these technologies can be a hinderance or a help depending on the size of your operation.
Upvotes: 1
Reputation: 2652
Yes, there is a way to deploy a Spring Boot application as a GCP cloud function.
As mentioned in this article of May 26th, 2020:
The Google Cloud Java Frameworks team worked with the Spring team to bring Spring Cloud GCP project to help Spring Boot users easily leverage Google Cloud services. More recently, the team worked with the Spring Cloud Function team to bring you Spring Cloud Function GCP Adapter. A function can just be a vanilla Java function, so you can run a Spring Cloud Function application on Cloud Functions without having to modify your code to run on Google Cloud.
@Bean public Function<String, String> uppercase() { return value -> value.toUpperCase(); }
Please have a look at this GitHub repository as it contains the full example.
Upvotes: 4