I am trying to deploy my first project to Google App Engine but getting some kind of build error.
The error messages are very obtuse though so I can't work out whether this is my fault or not.
This is my app.yaml:
runtime: nodejs
env: flex
env_variables:
BUCKET: 'xyz'
MONGODB_URI: 'mongodb://xyz'
The error messages in the logs:
72681 silly finalize /app/node_modules/grpc/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/gauge/node_modules/lodash.padstart/node_modules/lodash._baseslice
The command '/bin/sh -c npm install --unsafe-perm || ((if [ -f npm-debug.log ]; then cat npm-debug.log; fi) && false)' returned a non-zero code: 1
ERROR
ERROR: build step "gcr.io/cloud-builders/docker#sha256:d03a22d793930dbfedfa52e0975340a76fd921af28252172e82feef09b9a0a37" failed: exit status 1
72682 silly finalize /app/node_modules/grpc/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/gauge
If someone could at least pinpoint the module or section that is causing this build to fail that would at least point me in the right direction. Any help at all would be appreciated!
Related
Each time I am trying to build and deploy my React Project on AWS Elastic Beanstalk using Docker, I am getting this error:
Stderr:fatal error: runtime: out of memory
The project is the basic react project and nothing more, serving it via nginx. What might be the reason of this error? And how do I resolve it. Please note, I have emptied my S3 bucket and have restarted the appServer too, to try and resolve any unnecessary memory or cache use. And I am able to successfully build and run this file locally. The logs are as follows:
Step 1/9 : FROM node:alpine as builder
---> eb56d56623e5
Step 2/9 : WORKDIR '/app'
---> Using cache
---> 41d7415dae07
Step 3/9 : COPY package.json .
---> Using cache
---> 95877ba9972c
Step 4/9 : RUN npm install
---> Using cache
---> c366758de80f
Step 5/9 : COPY . .
---> 5697eace7031
Step 6/9 : RUN npm run build
---> Running in 52cc1a3e6ac0
> react-project-frontend#0.1.0 build
> react-scripts --openssl-legacy-provider build
Creating an optimized production build...
2022/03/03 13:14:45.346275 [WARN] failed to execute command: docker build -t aws_beanstalk/staging-app /var/app/staging/, retrying...
2022/03/03 13:14:45.425369 [INFO] Running command /bin/sh -c docker build -t aws_beanstalk/staging-app /var/app/staging/
2022/03/03 13:14:47.001398 [ERROR] An error occurred during execution of command [app-deploy] - [Docker Specific Build Application]. Stop running the command. Error: failed to build docker image: Command /bin/sh -c docker build -t aws_beanstalk/staging-app /var/app/staging/ failed with error exit status 2. Stderr:fatal error: runtime: out of memory
You docker image does not enough memory allocated:
In the ElasticBeanstalk application environment Dockerrun.aws.json, you can increase the memory allocation ("memory": 80 to e.g. "memory": 100):
"containerDefinitions": [
{
"name": "request_repeater",
"image": "my/image",
"essential": true,
"memory": 80, <- change this
Also, maybe you need to change the instance type. For example the t2.nano has a max memory of 0.5 GB
You can do this in Modify capacity settings when you are creating your application, or edit in Configuration > Capacity setting on the current env configuration.
Our nodejs application works fine in GAE Standard. But we need to use websockets so we are going with Flex. However we are running into all sorts of build-time issues with Flex.
So we want to deploy a GAE Flex with a gcp-build step, but are getting all sorts of errors such as:
Step #1: error building image: error building stage: symlink /app/packages/node_modules/autoprefixer/bin/autoprefixer /app/packages/client/node_modules/.bin/autoprefixer: file exists
and also, after patching that, comes this error:
error building image: read tcp 192.168.10.2:54502->74.125.20.128:443: read: connection reset by peer
We are on a mono-repo app with lerna and our gcp-build script just does: yarn build which subsequently does: "build": "lerna run build --scope=client --scope=server --scope=common --stream"
We have a hunch that gcp-build is only for the standard env and not flex. If that is truly so, how would you recommend us to run a build step in GAE Flex? And if not, what is with all these 'building image' errors? All is fine in GAE Standard with the same code!
Finally got our flex server running. So here are the answers to my initial questions:
Firstly, the error Step #1: error building image: error building stage: symlink /app/packages/node_modules/autoprefixer/bin/autoprefixer /app/packages/client/node_modules/.bin/autoprefixer: file exists was solved by running yarn build && rm -rf ./packages/client/node_modules in our gcp-build step.
Cannot repro the second error about error building image: read tcp 192.168.10.2:54502->74.125.20.128:443: read: connection reset by peer and later found that it was probably due to my internet connection dropping out during the deployment as advised by a gcloud support agent quoted below:
It means that the build failed because the library was absent, this IP did not respond at this time.
Lastly, regarding the third question about whether gcp-build is only for the standard env and not flex. It's not true. It works in both standard and flex as quoted by the same agent:
Regarding the question about that ‘gcp-build’ is only for the standard env and not flex, that is not correct, you can use gcp-build, in the App Engine Standard and Flex [1].
I am using elastic beanstalk from AWS to deploy and host a react application using Docker.
The deployment fails mysteriously, even though I succeed building the Docker image on my local machine.
An inspection to the logs on the EC2 instance (using eb ssh) does not provide more explanation that this:
--------------------------------
/var/log/eb-commandprocessor.log
--------------------------------
Step 5/14 : COPY package.json /usr/src/app/package.json
---> Using cache
---> f06f2c9d6519
Step 6/14 : RUN npm install
---> Running in 9926fc11431f
The command '/bin/sh -c npm install' returned a non-zero code: 1
Failed to build Docker image aws_beanstalk/staging-app: 2c9d6519
I even tried to run the npm install command inside the last layer of the built container using
sudo docker commit 9926fc11431f test && docker run -it test bash
cd /path/to/wordir
npm install
But the return code is actually 0
Is there any other way this could fail and logs return me wrong errors ?
I'm writing this answer for any future people which come by this. If there is no NPM error message. The issue is memory exhaustion there are two ways to resolve this on Beanstalk specifically:
Use a machine with more memory (instead of say a t2.micro)
(recommended) Switch to yarn. Yarn uses much less memory than npm.
Figure out some other way to reduce your memory footprint
This issue gave me a lot of headache so I hope this helps future folks who come across this issue.
I am trying my hands on Go, and started with the go1.11 beta.
The first Hello world example worked fine and I was able to view it via the browser.
In my second attempt, I created multiple .go files (main.go, datastore.go).
I am able to run it locally and it works fine.
However when I attempt to deploy, I get the following error (deployment in first example worked just fine):
gcloud app deploy
...
File upload done.
Updating service [default]...failed.
ERROR: (gcloud.app.deploy) Error Response: [9] Cloud build 67d67177-13cd-4e80-980a-ea36a0760678 status: FAILURE.
Build error details: go build: cannot use -o with multiple packages
On the server, the build logs show:
Step #1 - "builder": building app with command '[go build -o /tmp/staging735225713/usr/local/bin/start ./...]', env '[PATH=/go/bin:/usr/local/go/bin:/builder/google-cloud-sdk/bin/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin HOSTNAME=d0f271c7f5b8 HOME=/builder/home BUILDER_OUTPUT=/builder/outputs DEBIAN_FRONTEND=noninteractive GOROOT=/usr/local/go/ GOPATH=/go GOPATH=/tmp/staging735225713/srv/gopath]': err=exit status 1, out=go build: cannot use -o with multiple packages
Finished Step #1 - "builder"
ERROR
ERROR: build step 1 "gcr.io/gae-runtimes/go111_app_builder:go111_20181212_RC00" failed: exit status 1
What am I doing wrong?
UPDATE:
Tried various things, including subfolder or a 'vendor' folder as suggested, but no avail.
Updating service [default]...failed.
ERROR: (gcloud.app.deploy) Error Response: [9] Cloud build 79c39e82-3185-4ae1-a7ff-6afa1be448e7 status: FAILURE.
Build error details: srv/proto/myfile.pb.go:8:2: cannot find package "github.com/golang/protobuf/proto" in any of:
/usr/local/go/src/github.com/golang/protobuf/proto (from $GOROOT)
/tmp/staging770905501/srv/gopath/src/github.com/golang/protobuf/proto (from $GOPATH)
This is the error I get in the logs when deploying a RUBY app.
ERROR
Finished Step #1 Step #1: The command '/bin/sh -c bundle install
--deployment --without="development test" && rbenv rehash' returned a non-zero code: 18
Going off of the little info you provided and a similar issue I encountered, I'm thinking you were deploying a Rails app in a flex environment. Check out how it decides which Ruby version to use: https://cloud.google.com/appengine/docs/flexible/ruby/runtime. It may help to create a .ruby-version file in your app's root directory as specified. In my case, I specified the wrong version in my .ruby-version file: it didn't match up with the version in my Gemfile, so it gave me this error message:
Step #1: Step 14/17 : RUN bundle install --deployment --without="development test" && rbenv rehash
Step #1: ---> Running in <some random hash>
Step #1: Your Ruby version is 2.4.1, but your Gemfile specified 2.5.5
Step #1: The command '/bin/sh -c bundle install --deployment --without="development test" && rbenv rehash' returned a non-zero code: 18
Did you try bundle update. It's working for me