According to the docs found here:
https://cloud.google.com/appengine/docs/standard/php7/runtime#application_startup
My app, is able to serve up index.php, without defining any handlers in my app.yaml file, which it does. Great! However, that same app.yaml file fails to serve up index in my local environment (dev_appserver.py) That seems less than ideal...
The path to the file is public/index.php
Here's the error I see in my local when I go with the very same app.yaml that works perfectly in production:
The url "/" does not match any handlers.
The dev_appserver.py only works with the first generation App Engine runtimes.
As you can see on the documentation, to test locally your PHP 7 app, you have to use the development tools that you usually use.
On this thread from the Google’s Public Issue Tracker there is a similar issue, and there is posted a solution for locally test PHP 7 apps. Basically, you have to set up a front controller on a web server locally. You can do it following this tutorial, for example.
Related
I'm using GCP App Engine with auto scaling.
If I deploy a new version of the app code (Python 3 Flask app) with a simple change for control and test purposes, lets say I add a comment to one of the .js files I am not seeing that change to the file in the browser after it has been deployed.
I have 100% of traffic being served by the new version of the app. When I look at the source code for the version I can see the comment in there, but when I clear my browser cache and visit the page I only ever get the old version of the page (without the comment in the .js).
I have tried using the --promote and --no-cache values in the app deploy command, but no use. I have added:
default_expiration: "0d 0h 0m 0s"
To the app.yaml
I have also turned on object versioning of the storage account which app engine uses to try to ensure that only a single version of the file is available to be served - still no use.
The command I'm using to deploy is:
run: "gcloud app deploy app.yaml --quiet --promote --no-cache"
I can't understand why it should be so difficult to simply deploy a new version of the app and have the app engine serve the latest files; I must be doing something wrong but cannot see what.
Would appreciate any pointers.
The files are cached (even if for a short while and sometimes it takes time to clear it).
The trick is to make the urls (for the static files) unique for each deployment. This way, the browser is loading a 'distinct' url after each deployment. For example, you could append the environment variable, CURRENT_VERSION_ID to the url for all static elements. This means having something like (assuming Python/Jinja2)
src="/static/js/my_js_file.js?{{CURRENT_VERSION_ID}}"
os.environ['CURRENT_VERSION_ID'] changes for each deployment. There's a possibility this attribute is not available in newer runtimes. If so, just dump the environment variables and look for an attribute that is always present but the value changes (e.g. GAE_INSTANCE).
You could also just generate a random number each time your App is deployed and use that instead i.e.
src="/static/js/my_js_file.js?{{RANDOM_NUMBER}}"
I am using Google App Engine to deploy a node app (nextjs, node-12).
To deploy the app, I run:
gcloud app deploy
My app.yaml is as follows (minus variable substitutions):
runtime: nodejs12
env_variables:
NEXT_PUBLIC_FRONTEND_URL: "A"
In my code is the following line:
const url = `${process.env.NEXT_PUBLIC_FRONTEND_URL}/login/callback`;
When this code runs in app engine, url evaluates to B/login/callback
I don't understand this behavior. The documentation here (https://cloud.google.com/appengine/docs/standard/nodejs/config/appref) seems to indicate to me that this should work, but it does not.
Is there a reason for this? I've unset the variables from my local computer, just in case they were somehow getting passed, and I removed the .env file in case nginx was sourcing it or something like that.
What you have done looks correct. Try the following troubleshooting steps
Confirm you are not directly setting the value somewhere in your code e.g. say you call a child process and pass an env to it and you have explicitly set the value there
Check your deployed versions (you can do this via cloud console, see path below). Do you have multiple versions of the app? Which one are you running?
To check your versions and which one is running
console.cloud.google.com > App Engine > Versions
To view the configuration for each of the deployed versions,
select the version and click on 'View' under the 'config' column . This will display the deployed app.yaml file for that version
I inherited a App Engine static-file-only service and I am still trying to understand it (contract developers, long gone, docs=0). One point that I am stuck on is why in the Debugger Source display I don't see the static file directory. This is a Python 2.7 app and to be clear there is no Python code provided. The app.yaml file looks like this:
service ya-da
runtime: python27
api_version: 1
threadsafe: true
handlers:
- url: /
static_files: dist/index.html
upload: dist/index.html
It is a SPA, so it just one html file and lots of bundled JS & CSS.
This is what I see in App Engine Debugger source display
So no dist directory is shown. But it is there as the app is running happily. There is nothing tucked into any other directory (most of them are utterly useless in the App Engine context) that would be the contents of dist.
So, the simple question is: why doesn't dist show up in the debugger?
given that you have found an issue related with the debugger, you can file an issue in the Public Issue Tracker of Google Cloud Platform with the components of Debugger Stackdriver here. In this way, the Stackdriver Engineers team have visibility of this issue and other users with the same issue can star it and follow it.
From your comment to my other answer, it seems you just need access to code that was deployed.
It looks like you are using GAE standard first generation so you should be able to download your code as described here. This is the command:
appcfg.py -A [YOUR_PROJECT_ID] -V [YOUR_VERSION_ID] download_app [OUTPUT_DIR]
That page has deprecation warnings because Google is encouraging people to migrate to GAE second generation, but I expect that will work for you.
Your static files don't show up in the debugger because GAE treats static files very differently than it does your code.
The point of having static files is to be able to serve them without burdening your GAE instances. The app.yaml file has a an upload option because you are telling GAE where to put your static files, and this location is separate from where your code is uploaded.
The debugger is for debugging code. It is not possible to debug a static file because there is no code (Well, no server code. Your Javascript runs in the browser.) and there is nothing to debug.
What is it you are trying to accomplish? Your Javascript is running on the front end so you can't debug it on the backend.
Although I started development for Google App Engine using Endpoints a while ago, I hadn't noticed this - Google's ref. page for Project structure says this:
Your development file hierarchy should look like this:
MyDir/
[pom.xml]
[build.gradle]
[index.yaml]
[cron.yaml]
[dispatch.yaml]
src/main/
appengine/
app.yaml
docker/
[Dockerfile]
java/
com.example.mycode/
MyCode.java
webapp/
[index.html]
[jsp.jsp]
WEB-INF/
[web.xml]
You'll need to define an app.yaml file that looks like this:
...
Note that the app.yaml is deemed compulsory as per the docs. In my case, I spawned a backend module(through the Wizard) in Android Studio that builds on Gradle. I have been able to build and deploy this module on GAE successfully but now I needed to switch from automatic scaling to basic/manual scaling, I found this to be done through app.yaml file.
Here is the thing: I don't have an app.yaml in place and it works fine. Where is then the config info. that GAE requires to deploy the App.
Specifically,
app.yaml specifies the environment - Java. But, I found the java plugin in build.gradle for that. Aren't 2 config places for the same thing confusing?
Is it possible to ditch app.yaml entirely for equivalent config. in build.gradle?
Why is Google claiming app.yaml to be compulsory when I am able to do without it?
The App Engine Java runtime uses its own configuration schema in XML, while others are YAML.
To set the scaling elements, follow the official reference.
This is a how to question as not many information is available. I do, however, took the time out to investigate and tried their simple Hello World app which works great.
Now I tried to use Polymer Starter Kit git clone along with the Hello World tutorial, except for the git clone.
In my testapp folder, for the starter kit, I have added an app.yaml. Inside has the same config as the hello world:
runtime: nodejs
vm: true
api_version: 1
To deploy: gcloud preview app deploy app.yaml --set-default
After all that has completed, it gave me the url to preview the app. Note that the starter kit works on my local machine. The url gave me 503. So I waited for an hour and same 503. In my Dev Console - VM Instances, under Name, I see many instances. Is that correct? Is there a tutorial to get the starter kit on Google Cloud Platform running on nodejs?
As far as I know, the Polymer Starter Kit runs via gulp serve when in development, and that will be listening on a port like 5000 or 7000. If you read the Custom Runtimes or Managed VMs docs, you'll see that by default, requests to your app are routed to port 8080. However, you shouldn't run the development server in production. You should actually build the project and serve from the build version.
Instead of gulp serve, you should rather just run gulp to build and vulcanize the project. The dist/ folder will then contain the version of your app ready to deploy, and you'll need to look into that folder and realize that it's meant to be served as a static website. You therefore shouldn't need to use nodejs to serve it, and you'll save a ton of money from having everything in the static files network edge-cache, and not needing to use any real instance compute power.
You can find online examples of app.yaml files which can be used to deploy a static website on App Engine without the need to use any dynamic instances to serve anything.