ISSUE:
The ERROR: (gcloud.app.deploy) Error Response: [9] is typically caused by a dependency issue that results in an error of not found.
This similar issue, or sh: 1: ng: not found, has been reported and worked-around by using creating a Dockerfile here.
In this original post, it appears that yarn start v0.21.3 is the issue.
SOLUTION: An Angular2 project created by using the angular-cli will contain the root package.json file with a devDependencies section like the example below:
"devDependencies": {
"@angular/cli": "1.4.2",
...
...
},
NOTE: To get any other dependencies, like @angular/material and commands like yarn start v0.21.3 to work. The Dockerfile must include the commands to install those dependencies via command line.
Create an app.yaml and Dockerfile within the same path of the package.json file like the example below:
angular2-example-app
├── e2e
├── node_modules
├── src
├── package.json
├── app.yaml
├── Dockerfile
The app.yaml file will need the following settings: (app.yaml documentation):
# [start app_yaml]
runtime: custom
env: flex
The Dockerfile will need all the commands a user could call on the command line to assemble an image.
Note: npm install -g @angular/cli command being ran in the example below:
FROM alpine:latest
MAINTAINER yourname
# update alpine linux
RUN apk update && apk upgrade && \
apk add nodejs && \
# may comment this line in my computer.
apk add nodejs-npm && \
npm install -g @angular/cli
# add source code to images
ADD . /angular2-example-app
# switch working directory
WORKDIR /angular2-example-app
# install dependencies
RUN npm install
# expose port 4200
EXPOSE 4200
# run ng serve on localhost
CMD ["ng","serve", "--host", "0.0.0.0", "--disable-host-check"]
Deploy the app to your google cloud App Engine: gcloud app deploy
(gcloud documentation)
gcloud app deploy. I did already have to move"@angular/cli": "^1.0.0"intodependenciesin addition todevDependenciesinpackage.jsonas there was an issue with not having@angular-cliinstalled and the script trying to runng serveand failing. So just to make sure that there was no issue with my app in Google Cloud I downloaded and deployed thecloud-cardboard-viewersample project at codelabs.developers.google.com/codelabs/cloud-cardboard-viewer/… and that deployed without issue. Again, I have no issues running locally.