Use of gcloud app deploy using sdk always results in error - google-app-engine

I am using the following app.yaml. I am trying to deploy my angular app. Tried to use 3 different variants of the sdk but everytime it throws an error. - 218 -201- 215
runtime: custom
env: flex
threadsafe: true
automatic_scaling:
min_num_instances: 1
max_num_instances: 10
cool_down_period_sec: 120 # default value
skip_files:
- ^(.*\/)?.*\.py[co]$
- ^(.*\/)?.*\.py$
- ^(.*\/)?.*/RCS/.*$
- ^.git(.*\/)?
- ^(.*/)?.*\.bak$
- ^(.*)?\/?src[\/]?(?:(.*)?[\/]?)$
- ^[\.]?ssl(.*[\/]?)?$
- ^[\.]?idea(.*[\/]?)?$
- ^[\.]?e2e(.*[\/]?)?$
handlers:
- url: /
static_files: dist/index.html
upload: dist/index.html
application_readable: true
- url: /
static_dir: dist
application_readable: true
- url: /favicon\.ico
static_files: favicon.ico
upload: favicon\.ico
application_readable: true
- url: /(.+\.(gif|png|jpg|js|css|json|woff2|svg|ttf|eot|woff))$
static_files: \1
upload: .+\.(gif|png|jpg|js|css|json|woff2|svg|ttf|eot|woff)$
application_readable: true
But I am always ending up with the error
gcloud components update --version 185.0.0
ERROR: gcloud crashed (TypeError): unsupported operand type(s) for
+=: 'int' and 'NoneType'
If you would like to report this issue, please run the following
command:
gcloud feedback
To check gcloud for common problems, please run the following
command:
gcloud info --run-diagnostics
Could someone guide me with this?
Note: I was able to deploy successfully a couple of days ago with the version - 201.

I am unsure as to why . I am everybit confused as well. I removed all the comments I had for "skip_files" section and then it allowed me deploy without any errors
api_version: 1
runtime: python
env: flex
threadsafe: yes
readiness_check:
check_interval_sec: 120
timeout_sec: 40
failure_threshold: 5
success_threshold: 5
app_start_timeout_sec: 1500
skip_files:
- ^(.*/)?#.*#$
- ^(.*/)?.*~$
- ^(.*/)?.*\.py[co]$
- ^(.*/)?.*/RCS/.*$
- ^(.*/)?\..*$
- ^(.*/)?.*\.bak$
- ^(.*/)?.*\.yaml$
- ^node_modules/(.*/)?
- ^src/(.*/)?
handlers:
- url: /
static_files: dist/index.html
upload: dist/index.html
- url: /
static_dir: dist

Related

Unable to open google app engine application on my custom domain

I have a React + Flask application deployed on Google App Engine and mapped to my custom domain. I deployed a new version 3 days ago, it was working properly until today. On my custom domain, I cannot open some pages. I checked the console, apparently, the application were unable to load the js packages, and one of the error is
GET https://MY_DOMAIN/static/js/main.4eaaa8ad.chunk.js net :: ERR_ABORTED 404.
I also check the App Engine version instance, the MY_PROJECT.appsport.com is working properly.
I was wondering whether I made an error on the app.yaml file or I mapped the DNS incorrectly.
My app.yaml is this :
runtime: python37
env: standard
default_expiration: '5m'
entrypoint: gunicorn -b :$PORT main:app --timeout 150
instance_class: F4
automatic_scaling:
max_instances: 5
min_instances: 1
min_pending_latency: '5s'
target_cpu_utilization: 0.75
inbound_services:
- warmup
handlers:
- url: /static/js/(.*)
static_files: build/static/js/\1
upload: build/static/js/(.*)
- url: /static/css/(.*)
static_files: build/static/css/\1
upload: build/static/css/(.*)
- url: /static/media/(.*)
static_files: build/static/media/\1
upload: build/static/media/(.*)
- url: /(.*\.(json|ico))$
static_files: build/\1
upload: build/.*\.(json|ico)$
- url: /
static_files: build/index.html
upload: build/index.html
- url: /.*
script: auto
I have also noticed that I actually did not set the $PORT environment variable, could this be a potential problem?
Add the static_dir in handlers of your app.yaml to serve the static files of your application:
handlers:
- url: /static
static_dir: build/static/
- url: /static/js/(.*)
static_files: build/static/js/\1
upload: build/static/js/(.*)
- url: /static/css/(.*)
static_files: build/static/css/\1
upload: build/static/css/(.*)
- url: /static/media/(.*)
static_files: build/static/media/\1
upload: build/static/media/(.*)
- url: /(.*\.(json|ico))$
static_files: build/\1
upload: build/.*\.(json|ico)$
- url: /
static_files: build/index.html
upload: build/index.html
- url: /.*
script: auto

GCP AppEngine favicon.ico not found

Been pulling my hair trying to figure out why can't favicon.ico loads properly. Needed help from Google Cloud AppEngine gurus.
The project is a React App where gcp-build will generate a build folder with favicon.ico in it.
Consider the following cloudbuild.yaml:
steps:
- name: node:12
args: ["yarn"]
- name: node:12
args: ["yarn", "gcp-build"]
- name: node:12
args: ["rm", "-rf", "node_modules"]
- name: "gcr.io/cloud-builders/gcloud"
args: ["app", "deploy", "--version=mark0"]
timeout: "1600s"
And app.yaml looks like:
service: react-demo
runtime: nodejs12
handlers:
- url: /favicon.ico
static_files: build/favicon.ico
upload: build/favicon.ico
Hitting the page https://react-demo-dot-xxxx-xxxxx.df.r.appspot.com/favicon.ico will always get a 404 error.
Can anyone help please?
To debug if it's an issue with either the Cloud Build steps, the deployment or the runtime itself (notice that the Nodejs 12 runtime is currently in beta), build the React App locally and try to deploy the application directly by using gcloud app deploy, with the following app.yaml file:
runtime: nodejs10
service: react-demo
handlers:
- url: /static/js/(.*)
static_files: build/static/js/\1
upload: build/static/js/(.*)
- url: /static/css/(.*)
static_files: build/static/css/\1
upload: build/static/css/(.*)
- url: /static/media/(.*)
static_files: build/static/media/\1
upload: build/static/media/(.*)
- url: /(.*\.(json|ico))$
static_files: build/\1
upload: build/.*\.(json|ico)$
- url: /
static_files: build/index.html
upload: build/index.html
- url: /.*
static_files: build/index.html
upload: build/index.html
Turns out that there's a dispatch.yaml deployed unbeknownst to me using CLI and not committed into codes. In that dispatch.yaml it was directing all */favicon.ico towards default service. One lesson that I've learned is to scour for logs, in this instance, there are no 404 errors logged in the supposed service but it was abundant in the logs of the default service.
Hopefully this would help others in troubleshooting.

Google App Engine ignores context path

I have the following context path handlers in my app.yaml:
runtime: nodejs
env: flex
resources:
cpu: 1
memory_gb: 1
disk_size_gb: 20
handlers:
- url: /api
secure: always
script: app.js
- url: /
secure: always
static_dir: public
Static works OK. There are two problems i have:
secure: always
pragma does not work as expected. There's no redirect from http to https.
Second, i have /test endpoint in my NodeJS app. However /api/test is 404, but /test works, ignoring /api.
What am I doing wrong?
Generated runtime config:
runtime: nodejs
api_version: '1.0'
env: flexible
threadsafe: true
handlers:
- url: /api
script: app.js
secure: always
- url: '/(.*)'
secure: always
application_readable: false
static_files: "public/\\1"
require_matching_file: false
upload: 'public/.*'
automatic_scaling:
min_num_instances: 2
max_num_instances: 20
cpu_utilization:
target_utilization: 0.5
resources:
cpu: 1
memory_gb: 1
disk_size_gb: 20
As stated in this answer, the flex environment doesn't support the handlers section in app.yaml. That post also has a couple of examples of how to get this up and running in nodejs.
The second half of your question has a similar answer - you need to implement these redirects in your node app directly.

Google AppEngine Yaml PHP Handler Issue

Really simple setup; I just want to access any php file from the api folder (technically would like to specifiy /api/.* or something along that lines to include any subfolders) but this setup only returns 404; I have a feeling it is completely ignoring this line - url: /api/app/(.+\.php)$ because if I type asdfasdf.appspot.com/api/app/main.php (there is a main.php in the root directory) it loads. So this tells me it is staying in the root path the whole time. Any suggestions?
application: fsfhakjsldhf9
version: 1
runtime: php55
api_version: 1
threadsafe: yes
env_variables:
MYSQL_DSN: mysql:unix_socket=/cloudsql/fudfsy9:us-central1:fuasdfe-prod1;dbname=f25dsfss9
MYSQL_USERNAME: fddadfs
MYSQL_PASSWORD: 'asfdasdff'
MYSQL_DATABASE: 'asdfasdf'
handlers:
- url: /favicon\.ico
static_files: favicon.ico
upload: favicon\.ico
- url: /files
static_dir: files
- url: /api/app/(.+\.php)$
script: \1
secure: always
- url: /.*
script: main.php
The - url: /api/app/(.+\.php)$ also needed script: /api/app/\1 to match

Debugging 404 on GAE production server

I am receiving a 404 error for every file of my GAE project on the live server and I'm unsure of the next debugging steps
My directory structure is as follows:
| /project
|____ /build
|________ index.php
|________ other_project_files.php
Here are the relevant configuration handlers in app.yaml:
application: alex-young
version: 2
runtime: php
api_version: 1
threadsafe: true
default_expiration: "7d 0h"
skip_files:
- (.*/)?.*/node_modules/.+
- (.*/)?.*/src/.+
- (.*/)?.*/gruntfile\.js
- (.*/)?.*/todo\.txt
handlers:
# - url: /robots.txt
# static_files: robots.txt
# upload: robots.txt
- url: /Alexander\ Young\ -\ Resume.pdf
static_files: build/Alexander\ Young\ -\ Resume.pdf
upload: build/Alexander\ Young\ -\ Resume.pdf
- url: /css
static_dir: build/css
- url: /img
static_dir: build/img
- url: /js
static_dir: build/js
- url: /partials
static_dir: build/partials
application_readable: true
- url: /templates
static_dir: build/templates
application_readable: true
- url: /utils
static_dir: build/utils
application_readable: true
- url: /mustache
static_dir: mustache
application_readable: true
- url: /(.*\.(gif|png|jpg|ico|js|css|eot|svg|ttf|woff))
static_files: \1
upload: (.*\.(gif|png|jpg|ico|js|css|eot|svg|ttf|woff))
- url: /(.+\.php)$
script: build/\1
- url: /
script: build/index.php
The logs simply show a 404 error and no other information. My entire project loads fine on my local machine's MAMP and GAE test servers. I have no idea where to look for errors. Does GAE provide any more details other than Logs?

Resources