Failed build Google App Engine App with React - google-app-engine

Hi I have to deploy sy gcp engine of a react app after running the build I launch the gcloud deploy command and I have the following error on google cloud platform console:
How can fix this?
Error:
ERROR:
build step 2 "us.gcr.io/gae-runtimes/buildpacks/google-gae-18/nodejs/builder:nodejs16_20230116_16_19_0_RC00"
failed:
step exited with non-zero status: 145
app.yaml:
runtime: nodejs16
handlers:
- url: /
static_files: build/index.html
upload: build/index.html
- url: /(.*)$
static_files: build/\1
upload: build/(.*)

Related

GAE deployment error: "Cannot write multiple packages"

Upon moving my projects files to a new computer, I can no longer deploy to Google App Engine. I don't know how to deciper the error, and my Google searches turn up nothing. Here is what gets returned:
File upload done.
Updating service [default]...failed.
ERROR: (gcloud.app.deploy) Error Response: [9] Cloud build ca8b6f48-9892-449a-a6d8-b220182e8d7c status: FAILURE
Error ID: 4daa946e
Error type: UNKNOWN
Error message: go build: cannot write multiple packages to non-directory /layers/google.go.build/bin/main
Full build logs: https://console.cloud.google.com/cloud-build/builds/[build log address]
The project builds fine on my local machine. I'm not sure what I'm doing wrong here.
The app.yaml looks like this:
runtime: go114
instance_class: F1
env_variables:
BUCKET_NAME: "****.appspot.com"
handlers:
- url: /robots.txt
static_files: robots.txt
upload: robots.txt
- url: /styles
static_dir: styles
secure: always
- url: /scripts
static_dir: scripts
secure: always
- url: /.*
script: auto
secure: always
Thanks for any clues!

GCloud Error: Not Found The requested URL was not found on this server

I followed this steps to deploy my angular 8 application in Google Cloud
https://medium.com/#karthiksagar/how-to-deploy-angular-8-app-on-google-cloud-platform-gcp-cdd79e5cc5cf
My app.yaml is as follows
runtime: python27
api_version: 1
threadsafe: true
handlers:
- url: /
static_files: sofbox-angular/index.html
upload: sofbox-angular/index.html
- url: /
static_dir: sofbox-angular
I have placed the app.yaml file inside dist/ directory as mentioned.
I am able to access the main url- http://www.myridemate.com/
but when clicked on blog the link is not accessible - http://www.myridemate.com/blog
It gives below error
Error: Not Found The requested URL /blog was not found on this server.
Tried adding extra handler for /blog in app.yaml and it didn't work.
This same code is working in my local and also in hostgator - https://www.myridemate.alexvijayraj.com/blog
Not sure what I am missing here. Is there some extra configuration required in app.yaml or anything in GCP?
Error Message in App Engine Logs:
{
"time": "2020-09-17T03:58:28.682252Z",
"severity": "WARNING",
"logMessage": "Static file referenced by handler not found: sofbox-angular/blog"
}
The answer in this thread worked for me. Angular 6 routes not found on Google App Engine
Remember to remove the two handlers that are already on the .yaml file (-url: ...)
handlers:
- url: /(.*\.(js|css|svg|png)(|\.map))$
static_files: dist/\1
upload: dist/(.*)(|\.map)
- url: /.*
static_files: dist/index.html
upload: dist/.*

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.

What is the solution for the error when I deploy pubsub for PHP with App Engine?

I was working on google Pubsub with App Engine, to get notifications from google play about InApp subscriptions status.
When I deploy my app with the command "gcloud app deploy", error message comes:
ERROR: (gcloud.app.deploy) An error occurred while parsing file: [/home/testaccount/php-docs-samples/pubsub/app/app.yaml]
Unable to assign value 'pubsub.js' to attribute 'url':
Value 'pubsub.js' for url does not match expression '^(?:(?!^)/.|..|((.).*(?!$).)$'
in "/home/testaccount/php-docs-samples/pubsub/app/app.yaml", line 6, column 8
My app.yaml file:
runtime: php55
api_version: 1
threadsafe: true
handlers:
- url: pubsub.js
static_files: pubsub.js
- url: /.*
script: index.php
env_variables:
GOOGLE_PROJECT_ID: "testproject"
I have followed the insturctions in the linl:
Writing and Responding to Pub/Sub Messages
I did not modify app.yaml file, I do not know what is going on? I tried to deploy "Hello, World!" for PHP on App Engine" exmaple and it worked.
Please help me to solve it.
url should start with a slash. Try:
- url: /pubsub.js
static_files: pubsub.js
After a week searching about why I get HTTP error 500 (Internal Server Error) when I browse https://testproject.uc.r.appspot.com/, I got the reason, it was from app.yaml file, all errors came from php version.
Old app.yaml:
runtime: php55
api_version: 1
threadsafe: true
handlers:
- url: /pubsub.js
static_files: pubsub.js
upload: pubsub.js
- url: /.*
script: index.php
env_variables:
GOOGLE_PROJECT_ID: "testproject"
New app.yaml:
runtime: php72
handlers:
- url: /pubsub.js
static_files: pubsub.js
upload: pubsub.js
- url: /.*
script: auto
env_variables:
GOOGLE_PROJECT_ID: "testproject"
Thank God.

URLs not found after deploying create-react-app build to Google Cloud Platform

I've uploaded a create-react-app build (with an app.yaml file) to a GCP bucket. The app has then been deployed on a App Engine instance using the cloud shell.
Going to the app's root URL works fine. But going to example.com/anything returns the following error:
Error: Not Found
The requested URL /anything was not found on this server.
App.yaml file looks like this:
runtime: python27
api_version: 1
threadsafe: true
handlers:
- url: /(.*\.(html|css|js))
static_files: build/\1
upload: build/(.*\.(html|css|js))
- url: /
static_files: build/index.html
upload: build/index.html
You don't have a handler for /anything. If you want a catch-all url, use regex type handler:
- url: /.*
static_files: build/index.html
upload: build/index.html
or, if you want to serve them anything.html as a static file, put it in your build dir, and navigate to /anything.html. Your first handler is set up to map that url.

Resources