Deploy multiple applications from same project - google-app-engine

How can I deploy multiple applications from same or different language/runtime originating from a single project in google cloud app engine?

Deploying Multiple Services to Google Cloud App engine.
Create the following files in the app root directory
Create app.yaml file with content:
runtime: nodejs14
service: default
Create myserviceone.yaml file with content:
runtime: nodejs14
service: myserviceone
Create myservicetwo.yaml file with content:
runtime: nodejs14
service: myservicetwo
Deploy using command
gcloud app deploy --project your_project_id app.yaml myserviceone.yaml myservicetwo.yaml
This will deploy the default service as well as my service one and my service two. Check out your cloud console.
You can access them using:
https://myserviceone-dot-yourProjectID.appspot.com/ or
http://myserviceone.yourProjectID.appspot.com/
https://myservicetwo-dot-yourProjectID.appspot.com/ or
http://myservicetwo.yourProjectID.appspot.com/

Today, App Engine has a one-to-one correspondence with a Google Cloud Console project. You cannot deploy multiple "apps" in the same project. However, you might still be able to do what you want depending on your application(s).
App Engine has the concept of "services," which are independent aspects of your application. Your App Engine app can have many services and each service can have its own language/runtime and even be on different App Engine environments.
You could have say a Python service on App Engine standard environment that is used to serve your simple Flask site, could have service that serves an API written in Java 8 on the Standard Environment, and could have yet another service in say Node.js running in the App Engine flexible environment.
Your "default" service is defined in your app.yaml file. Your other services can be defined in different folders and can have either an app.yaml with their service definitions or you could name them something else like backend.yaml. See this simple Python project for the layout of the configuration files.
For more conceptual information about services on App Engine, see Microservices Architecture on Google App Engine.

Related

Serving static files efficiently in google app engine flexible python

I have an application in Google app engine flexible which is written in Python. It uses Flask framework for backend. Currently, the flask framework serves the static files using the following code.
#app.route('/<path:path>') #Catch All urls, enabling copy-paste url
def home(path):
return send_from_directory(CLIENT_APP_FOLDER, path)
This eats up resources for serving my website written in Angular.
I have been reading on how I could serve static files not using my app engine app. One suggestion is to use Google Cloud Storage for serving the static files but I am not able to understand how I could set my DNS so that
www.example.com serves from Google Cloud Storage and www.example.com/api serves app engine app.
Another suggestion is to use dispatch.yaml and deploy two services, one pointing to the app engine app and another serving the static files, but again I am unable to figure out what the static file serving service would look like. Also does it deploy two services on the same instance or does it create two instances? I want to optimize for cost and not spin up another instance.
There is 2 solutions for minimizing cost.
The first one is to use Cloud Run instead of appengine flex. You can deploy the same container but you pay only when you are serving request. It's in beta but it's really stable. And you can use custom domain
The second solution, if you keep your app engine flex, is to deploy a second service. This second service will serve the static resources. Use standard appengine, and customize your app.yaml for serving only static resources. Here the doc for python 2 but the configuration is language agnostic
Serving static resources don't create instances. In any case, you have 28h of standard instance free per day.

What is the difference between app engine and cloud endpoints when developing with Android studio?

I've been trying to do this for a while, but I'm confused as to the difference between the two applications.
I know that endpoints helps you expose an API and generate the client libraries that allow you to interact with your Android app.
But in the examples, it seems as though endpoints is the only code you write for the backend at all.
I thought that app engine was what the actual application ran on - that is, do I need a separate project with the app engine backend, then my android studio project with the Android app and the endpoints API, or does writing the endpoints API also serve as the app engine backend?
The endpoints backend API is just a piece of a GAE app functionality.
If you only have that functionality in your app you can extend it by adding the desired stuff to the existing app.yaml file (and the related app code), you don't have to create a new app. Especially if the endpoints functionality and the additional desired functionality are related.
You can also add endpoints backend support to an existing GAE app by merging the endpoints backend app.yaml content into the existing app's app.yaml file and adding the class file and API server file to the app's code.

Google App Engine's Web Application server and Apache Tomcat

I read this sentence in google resources for GAE : "Google App Engine has it's own Web Application Server for simulating in desktop environment", so, my question is: Can I deploy Google App Engine apps (in .war format) on TomCat?
Thanks for any help!
the short answer is: it depends
according to the app engine doc:
App Engine Java applications use the Java Servlet standard for
interacting with the web server environment.
so for a simple servlet app, it can be run on tomcat
but
The App Engine runtime environment imposes some constraints to ensure
that your app can be scaled to multiple instances on App Engine's
distributed infrastructure
if you have used apis from app engine such as UserService, or Datastore then you are not able to run it on tomcat. in this case, you can use the development web server from app engine sdk for dev and test purpose.

package of google app engine project

HI I m new to google app engine,and I want to know is there an option in app engine to create a installer package of a project which can be deployed in other google app domains.So basically project will not be hosted publically but only for particular google app domains
An analogy I m looking here is salesforce package,where a developer can create a package url,through which package can be installed in other orgs. The project is not hosted publically. http://appexchange.salesforce.com/
You can package your source easily. The only variable that needs to change is in app.yaml application: field in python and appengine-web.xml in java. This will allow you to deploy the app in other domains.
As far as the package url that isn't how App Engine works. You can set your application to allow only certain domains to access it and provide an API for integrating it into another application, but that is different than Sales Force package url.
When developing a Google App Engine application you don't have to specify the url of the project. So you can install and deploy your application to several organizations or even subprojects.
The only thing you need to set is the application name in the app.yaml (in case you are using python) or appengine-web.xml (for java)
So for developing an installer I would create a script that first asks the user for the name of the application they want to deploy to, modifying the configuration files accordingly, and then calls the normal appcfg.py installer.

Executable from Google App Engine project

Is it possible to create an executable file from a Google App engine project in Python?
Well... no. But there are open-source projects available that allow you to run your App Engine application locally, and that attempt to be compatible with Google's App Engine API.
For example, check out typhoonae:
http://code.google.com/p/typhoonae/
You could develop your application using the Google SDK, and then deploy it on a local machine using the TyphoonAE app server.

Resources