I tried to deploy a Nest JS app to App Engine through Google Build Cloud & Manually
Both tries gives same error Modules not found
Error when deploying manually through Shell
Error when dploying using clouf build
My cloudbuild.yaml
- name: node:14.15.1
entrypoint: npm
args: ["install"]
- name: node:14.15.1
entrypoint: npm
args: ["run", "build"]
- name: node:14.15.1
entrypoint: npm
args: ["run", "create-env"]
env:
- "_APP_LUNE_DEV_TOKEN=${_APP_LUNE_DEV_TOKEN}"
- "_BUCKET_NAME=${_BUCKET_NAME}"
- "_FIREBASE_API_KEY=${_FIREBASE_API_KEY}"
- "_FIREBASE_APP_ID=${_FIREBASE_APP_ID}"
- "_FIREBASE_AUTH_DOMAIN=${_FIREBASE_AUTH_DOMAIN}"
- "_FIREBASE_MESSAGING_SENDER_ID=${_FIREBASE_MESSAGING_SENDER_ID}"
- "_FIREBASE_PROJECT_ID=${_FIREBASE_PROJECT_ID}"
- "_FIREBASE_STORAGE_BUCKET=${_FIREBASE_STORAGE_BUCKET}"
- "_GOOGLE_APPLICATION_CREDENTIALS=${_GOOGLE_APPLICATION_CREDENTIALS}"
- "_LUNE_API_BASE_URL=${_LUNE_API_BASE_URL}"
- "_STRIPE_SECRET_KEY=${_STRIPE_SECRET_KEY}"
- name: "gcr.io/cloud-builders/gcloud"
args: ["app", "deploy"]
timeout: "1600s"
options:
logging: CLOUD_LOGGING_ONLY
My app.yaml
runtime: nodejs14
service: backend
What I'm doing wrong ?
The problem was caused by Nest Js CLI Aliases, When I changed src/example/service to ../example/service the deployment worked
It's recommended to use typescript aliases in tsconfig file instead of CLI
Related
I'm trying to publish a create-react-app on Gitlab, using its CI.
This is my .gitlab-ci.yml file:
stages:
- build
- pages
build:
image: node:16
stage: build
script:
- npm install
- npm build
artifacts:
paths:
- build/
pages:
image: alpine:latest
stage: deploy
variables:
GIT_STRATEGY: none # Do not clone git repo
script:
- mv build public
artifacts:
paths:
- public
rules:
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
But unfortunately I get this error:
This GitLab CI configuration is invalid: pages job: chosen stage does not exist; available stages are .pre, build, pages, .post.
What's wrong with my configuration?
You need to change your stages.
You have:
stages:
- build
- pages
but define:
pages:
image: alpine:latest
stage: deploy
The stage needs to match:
stages:
- build
- deploy <-------
I am trying to deploy my react app to GAE,
I use cloud build
At the end I am receiving this error:
ERROR: (gcloud.app.deploy) Error Response: [9] Cloud build 8a36fcd1-285e-49bc-a13f-b6aef9ae5c8f status: FAILURE
npm ERR! bindings not accessible from watchpack-chokidar2:fsevents
this is my app.yaml:
runtime: nodejs14
service: ***********
basic_scaling:
max_instances: 10
idle_timeout: 5m
resources:
cpu: 1
memory_gb: 0.5
disk_size_gb: 10
handlers:
- url: /.*
script: auto
secure: always
redirect_http_response_code: 301
this is the cloudBuild.yaml
steps:
- name: node
entrypoint: npm
args: ['install']
- name: node
entrypoint: npm
args: ['run','build']
- name: 'gcr.io/cloud-builders/gcloud'
args: ['app', 'deploy']
timeout: 1200s
timeout: 1200s
Please review your Jason file over the Script part:
"scripts": { "start": "node server",*****Here should be also include the entry point, where this server is pointing.
I suggest to update this value with something like:
"scripts": { "start": "react-scripts start",*** adding this value , we were able to replicate your case without any issue.
I also recommend to review this documents to get more details about and be able to compare your settings with the ones inside on this documentation:
app-engine-react-demo[1]
package.json[2]
You can take a look to this example :
Deploying a React App to Google’s App Engine[3]
See next stackoverflow post which also mentioned similar cases:
app-engine[4]
And finally review this document where first you need to run npm build command in order to upload the files and then run the deploy.
setup.sh[5]
[1]https://github.com/mikesparr/app-engine-react-demo
[2]https://github.com/mikesparr/app-engine-react-demo/blob/master/package.json
[3]https://blog.doit-intl.com/deploying-a-react-app-to-googles-app-engine-6efa8f4732c7
[4]Deploy create-react-app on Google App Engine
[5]https://github.com/mikesparr/app-engine-react-demo/blob/master/setup.sh
I'm having trouble setting up my yaml files for google app engine. The configuration works correctly when my app.yaml file is in the root of the project but if it is within a subdirectory it does not build the correct source. I suspect I need to set the dir: option in the build config, but I have tried multiple variations and I can't get it to work.
Working file structure, deployed app is ~3mb in size.
src
deployment
└── staging
└── build.yaml
app.staging.yaml
# build.yaml
steps:
- name: node:12
entrypoint: yarn
- name: node:12
entrypoint: yarn
args: ['build']
- name: "gcr.io/cloud-builders/gcloud"
args: ["app", "deploy", "app.staging.yaml"]
timeout: "1800s"
Not working file structure, deployed app is ~1kb in size.
src
deployment
└── staging
└── build.yaml
└── app.yaml
# build.yaml
steps:
- name: node:12
entrypoint: yarn
- name: node:12
entrypoint: yarn
args: ['build']
- name: "gcr.io/cloud-builders/gcloud"
args: ["app", "deploy", "deployment/staging/app.yaml"]
timeout: "1800s"
In both scenarios I am kicking off the deployment with:
gcloud builds submit --config deployment/staging/build.yaml
What should my dir: be set to in the build.yaml steps so that the build step knows to build from root? Is there any way to debug this locally without having to upload the source every time?
Thanks!
A
you cannot have the app.yaml and the cloudbuild.yaml in the same directory if you are deploying in a non-custom runtime. Please see this comment
I believe by default cloud build expects the app.yaml file to be in the uppermost directory. I'm not sure if it's possible to change this in the cloud build settings.
I am getting the following error in my google cloud build
Failed to trigger build: failed unmarshalling build config cloudbuild.yaml: yaml: line 12: could not find expected ':'
I can not pinpoint where exactly I am missing : in my cloudbuild.yaml file
steps:
# Install
- name: "gcr.io/cloud-builders/npm"
args: ["install"]
# Update submodules
- name: "gcr.io/cloud-builders/git"
entrypoint: "bash"
args:
- "-c"
- |
git config -f .gitmodules submodule.myprojectsubmodule.url https://source.developers.google.com/p/myproject/r/github_myprojectsubmodule
git submodule init
git submodule update
# Lint
- name: "gcr.io/cloud-builders/npm"
args: ["run", "lint"]
# Test
- name: "gcr.io/cloud-builders/npm"
args: ["run", "test"]
# Build
- name: "gcr.io/cloud-builders/gcloud"
args:
- kms
- decrypt
- --ciphertext-file=.env.enc
- --plaintext-file=.env
- --location=global
- --keyring=myproject
- --key=cloudbuild-env
- name: "gcr.io/cloud-builders/npm"
args: ["run", "build"]
# Deploy
- name: "gcr.io/cloud-builders/npm"
args: ["run", "deploy"]
I have added # Update submodules step using the following comment https://github.com/GoogleCloudPlatform/cloud-builders/issues/26#issuecomment-463465138
To be a valid yaml format, the git commands should be correctly aligned under the | symbol in Update submodules section.
# Update submodules
- name: "gcr.io/cloud-builders/git"
entrypoint: "bash"
args:
- "-c"
- |
git config -f .gitmodules submodule.myprojectsubmodule.url https://source.developers.google.com/p/myproject/r/github_myprojectsubmodule
git submodule init
git submodule update
A YAML validator could be useful in this case, for example https://codebeautify.org/yaml-validator.
I am running command "gcloud app deploy" from my "vue" app folder and at the last getting vue-cli error, attached snap for it.
it seems like vue-cli-service isn't installed this is my cloudbuild.yaml if it helps
steps:
- name: node
entrypoint: npm
args: ['install']
# Necessary for vue.js projects
- name: node
entrypoint: npm
args: ['install', '-g', '#vue/cli']
- name: node
entrypoint: npm
args: ['test']
- name: node
entrypoint: npm
args: ['run', 'build']
- name: "gcr.io/cloud-builders/gcloud"
args: ["app", "deploy"]
app.yaml:
runtime: nodejs12
handlers:
# Serve all static files with urls ending with a file extension
- url: /(.*\..+)$
static_files: dist/\1
upload: dist/(.*\..+)$ # catch all handler to index.html
- url: /.*
static_files: dist/index.html
upload: dist/index.html
Note: if your package.json isn't in your repository root you should define set in npm commands as:
- name: node
entrypoint: npm
# --prefix and path:
args: ['install','--prefix','myapp']
and for deployment in gcloud if app.yaml isn't in root either:
- name: "gcr.io/cloud-builders/gcloud"
args: ["app", "deploy","myapp/app.yaml"]
Are you trying to deploy the app on GAE ( Google App Engine )?
If you are, the error might be caused because of GAE is not compatible with nodejs ( npm ), you need to deploy it in GAE flex if you want to use Vue of that way.
Another option could be, build the vue app and deploy it with another runtime, for example: python server; using the build as a static site.