How to deploy a SpringBoot REST Application to Google App Engine? - google-app-engine

Tried
Subscribed trial for GoogleAppEngine.
1. INSTALLED GOOGLE APP ENGINE SDK
2. Downloaded the sample Java started code and deployed it. Working fine.
3. Used $appcfg.sh -A <appname> update target/appengine-try-java-1.0 to deploy
4. In this case, its a folder with all the webapp related stuffs
Question
In my case, I have a spring boot application which generates a jar file. It runs with a embedded container and I believe Google may have an alternate to deploy using Docker or some other way. But how?
There is no pointer or any details on how to run this in Google managed platform as far as I searched.
Any help or reference to documentation!! Alternates??

You can now use Google App Engine Java Flexible Environment - Java 8 Runtime:
https://cloud.google.com/appengine/docs/flexible/java/dev-java-only
It is Docker based
UPDATE:
You can now use Java 8 in App Engine Standard Environment:
Tutorial:
https://codelabs.developers.google.com/codelabs/cloud-app-engine-springboot/index.html
Example:
https://github.com/GoogleCloudPlatform/getting-started-java/tree/master/appengine-standard-java8/springboot-appengine-standard
Blog post:
https://cloudplatform.googleblog.com/2017/09/Java-8-on-App-Engine-Standard-environment-is-now-generally-available.html

Google App Engine still uses Servlet 2.5 that is below the requirements of Spring Boot (i.e. Servlet 3.0).
There is a way to workaround that, check the documentation for more details

Spring Boot requires Servlet 3.0 which GAE does not have. WorkAround is to have a "spring-boot-legacy" dependency. You can check further how to implement: https://github.com/scratches/spring-boot-sample-gae

Related

Why did Google remove Image API for App Engine running Python 3.7?

I am using Google Cloud Storage and I want to serve scaled images from it, Python 2 version of Google App Engine supported it via Images API but with Python3, they removed that API.
https://cloud.google.com/appengine/docs/standard/python3/python-differences
Cannot understand the intension behind removing such an import feature, upgrading to Python3 in Google Cloud environment sounds like a downgrade to me.
As you said, the proprietary App Engine APIs are not available in Python3.7. The main reason is because GCP is unbundling App Engine and now, you are no longer dependent on these APIs.
Currently, there are some third parties alternative solutions. In your specific case, and based on GCP documentation, I think that you can try to use Imgix or Rethumb.
Seems like Google is planning on adding it back to Python 3:
https://cloud.google.com/appengine/docs/standard/python3/services/access
To reduce runtime migration complexity, Google Cloud now supports a set of App Engine bundled services and their associated APIs on second-generation runtimes, which include Python 3, Java 11, and Go 1.12 or higher. Your app can call bundled services APIs for second-generation runtimes through language-idiomatic libraries.

Best way to create Cloud Endpoints 2.0 app with Objectify now that Android Studio 3 doesn't have endpoints modules

Back in Android Studio 2.0 you could just add a Cloud Endpoints 1.0 backend module and it would generate for you a sample project that used Objectify. It was very convenient.
However, Android Studio 3.0 no longer has this feature and Cloud Endpoints 2.0 requires you use IntelliJ Ultimate edition to generate a App Engine Standard Environment project. However... IntelliJ Ultimate edition costs $500 and it doesn't appear a sample project with Objectify is created... Sigh...
So my question is, what is the best way to create a sample Cloud Endpoints project that uses Objectify? Because as of right now there appears to be no clear way from reading the documentation unless you want to shell out $500 for IntelliJ Ultimate edition.
Am I missing something??
I would suggest using the sample app as a start. You can import it as a Gradle project to Android Studio. Adding Objectify manually shouldn't be too difficult from there.
In addition to what is commented in the previous answer, if there are any doubts regarding how to use Objectify with App Engine, you can check out this code for integrating Objectify on a Java application.
You can run it using Maven as this:
mvn clean package
mvn appengine:run
After running it locally, you can deploy the app and check it works correctly:
mvn appengine:deploy
Once you check it works and understand the code, you can integrate it with the sample app indicated in the previous answer and combine them to create your Endpoints project with Objectify.

Deploy Dropwizard on Google AppEngine

I have been trying to find a way to deploy a Dropwizard app on Google AppEngine, but I haven't found anything so far.
Judging by this question (and answer) I think it might not be possible.
I would like to be sure about that, and If it does work, I'd like to learn how.
There is a dropwizard fork called warwizard which apparently lets you create war files from your dropwizard code, but it has not been touched for over 6 months, which would likely make it difficult to work with using the dropwizard docs.
Dropwizard is just Jersey+Jackson+Jetty bundled together nicely. Jetty and App Engine won't get along (that is, App Engine is already running Jetty, so it doesn't want the application to provide its own).
You're probably best off using Jersey and Jackson without Dropwizard tying them together: http://blog.iparissa.com/googles-app-engine-java/google-app-engine-jax-rs-jersey/ & http://www.cowtowncoder.com/blog/archives/2009/11/entry_338.html
You can however, run Dropwizard on Google Compute Engine. Which is basically just linux VMs provided by Google, with access to their APIs if needed.
I manged to get my Dropwizard instance working by doing the following on GCE:
Install Java
sudo apt-get install java7-runtime-headless
Open firewall ports:
gcutil addfirewall rest --description="http" --allowed="tcp:8080
gcutil addfirewall admin --description="admin" --allowed="tcp:8081"
Copy file to GCE
gcutil --project={project-id} push {instance-name} {local-file} {remote-target-path}
Run your app
java -jar your-app.jar server your-config.yml
EDIT: there is also another alternative called wiztowar https://github.com/twilio/wiztowar which supports DW 0.6.2 only.
I've been trying to solve this issue for the past two month. Here are my findings:
1- Yes, you can deploy Dropwizard as a WAR file. You need to use some hacks like Wizard in a box or WizToWar
2- No! You can't deploy that WAR file on AppEngine standard environment.
Why?
The main issue is that AppEngine is using servlet-api v2.5 (which is more than 10 years old!) and has no plan to upgrade to servlet-api v3 or higher. Dropwizard on the other hand require servlet-api v3 or higher.
BUT wait! there is another option
You can deploy Dropwizard on App Engine Flexible Environment
App Engine Flex is still in beta, but I've heard it will be available for public usage in Q1 2017. If you want to use it now, you have to ask for that to be enabled for you.
How do you deploy on App Engine Flex?
-> I've put all the steps on doing that in a blog post here:
Deploying Dropwizard on App Engine Flex

Export/import datastore from/to Google App Engine

I want to export the datastore that I have running in App Engine into my local "standalone" version of the application. Anyone know how I can do that?
I've been looking around in the App Engine dashboard but can't find it.
Check out the docs on uploading and downloading data.
Gobo-Tools is designed for such tasks
It seems that there is no separate doc for java version of this except that it is said to do with com.google.apphosting.utils.remoteapi.RemoteApiServlet in the doc Nick provided.
Tip: If you have a Java app, you can use the Python appcfg.py tool by installing the Java
version of the remote_api handler, which is included with the Java runtime environment.
The handler servlet class is com.google.apphosting.utils.remoteapi.RemoteApiServlet.
Here is some relevant code example for java version of this API usage GAE/J datastore backup

How to configure Tomcat to run an Google App Engine + GWT application on Mac OS X?

Does anyone know a good tutorial on this?
What Tomcat version must be used?
You can't use Tomcat to run an App Engine app (unless it doesn't make use of any App Engine specific APIs - in which case, configure it as you would for any other servlet app). You need to use the provided SDK, or the Eclipse plugin, documented here.

Resources