I have built an Angular 7 application that works nicely when I do the ng serve
command from my local mac or from a remote centos server.
This application is using php
files that access MySQL data base both served on my google cloud.
Now after doing the gcloud app deploy
the last thing I see on the screen is the message:
[email protected] start /app
ng servesh: 1: ng: not found
and I am dead in the water.
I have tried so many different versions of app.yaml
and cloudbuild.yaml
file that I feel like i have not learned anything.
I have tried the same thing by starting with the very basic “Hero’s” app and get the same issue.
i.e.
ng new xxx
cd xxx
npm install
ng serve
Then I see the default Heros screen in my browser.
I then create this app.yaml
file
runtime: nodejs
env: flex
manual_scaling:
instances: 1
resources:
cpu: 1
memory_gb: 0.5
disk_size_gb: 10
service:
xxx
I then try to deploy using:
gcloud app deploy
When this finishes I get the message
Deployed service [xxx] to [https://xxx-dot-project.appspot.com]
When I go to that url, I get:
Error: Server Error
The server encountered an error and could not complete your request.
Please try again in 30 seconds.
The log file for this run is:
gcloud app logs tail -s xxx
Waiting for new log entries...
2019-05-04 15:27:35 xxx[20190504t102436] "GET / HTTP/1.1" 404
2019-05-04 15:27:35 xxx[20190504t102436] "GET /favicon.ico HTTP/1.1" 404
2019-05-04 15:28:56 xxx[20190504t102436] "GET / HTTP/1.1" 404
2019-05-04 15:32:45 xxx[prod] "GET / HTTP/1.1" 404
2019-05-04 15:32:50 xxx[prod] "GET / HTTP/1.1" 404
2019-05-04 15:33:06 xxx[prod] "GET / HTTP/1.1" 404
2019-05-04 15:33:10 xxx[prod] "GET /run HTTP/1.1" 404
2019-05-04 15:33:10 xxx[prod] "GET /favicon.ico HTTP/1.1" 404
2019-05-04 15:33:16 xxx[prod] "GET /run HTTP/1.1" 404
2019-05-04 15:33:16 xxx[prod] "GET / HTTP/1.1" 404
2019-05-04 15:33:19 xxx[prod] "GET /login HTTP/1.1" 404
2019-05-04 15:33:19 xxx[prod] "GET /favicon.ico HTTP/1.1" 404
2019-05-04 15:40:43 xxx[prod] "GET /login HTTP/1.1" 404
2019-05-04 15:40:46 xxx[prod] "GET /login HTTP/1.1" 404
2019-05-04 15:40:50 xxx[prod] "GET /login HTTP/1.1" 404
2019-05-04 15:40:50 xxx[prod] "GET / HTTP/1.1" 404
2019-05-04 15:40:53 xxx[prod] "GET / HTTP/1.1" 404
2019-05-04 16:01:50 xxx[20190504t105955] "GET / HTTP/1.1" 500
2019-05-04 16:01:51 xxx[20190504t105955] /bin/sh: 1: ng: not found
2019-05-04 16:06:19 xxx[20190504t105955] "GET / HTTP/1.1" 500
2019-05-04 16:06:20 xxx[20190504t105955] /bin/sh: 1: ng: not found
My question is can someone provide a trivial example of this process where the application runs in the google cloud?
4
Answers
Looks like the suggestion to go to firebase was the most useable option.
I am a lot closer to where I want to be and I now see a lot of useful extras.
After project is created publish your project on GitHub.
On GitHub Apps you have to install Google Cloud Build now, because it needs access to your repositories.
You also have to create a Google Cloud Project for your new application and enable Cloud Build and Cloud App Engine.
Please refer here for more details:-
https://medium.com/felixklauke/angular-google-cloud-build-app-engine-5e7c2038bdad
When deploying Ng7 application with PHP backend, I would rather advise you to use two different solutions:
ng build
and then deploy the artifacts, so there is even no need for the Angular tooling in the resulting package.You can deploy a SPA (like Angular) with an
app.yaml
similar to this:You’d need to build locally your angular project beforehand with a
ng build --prod
, otherwise you need to set apredeploy
command on your package.json, which will be called bygcloud app deploy
(e.g.predeploy": "npm run lint && npm run build -- --prod --aot"
). Also important, you need to make sure you ignore all files outside ofdist
folder with.gcloudignore
file. This will prevent google cloud to upload those files.https://github.com/mrdulin/angular-apollo-starter includes all those files