Yarn rw prisma migrate deploy error in google cloud build

Hi, I’m trying to create a CI/CD using google’s cloud build for my redwoodjs app.

Here is my cloudbuild.yaml

steps:

# build api image
- name: 'gcr.io/cloud-builders/docker'
  id: "api-img"
  args: ["build", "-f", "Dockerfile.api",  "--build-arg=WEB_URL=${_WEB_URL}", "--build-arg=FIREBASE_PROJECT_ID=${_FIREBASE_PROJECT_ID}", "-t", 'gcr.io/${PROJECT_ID}/lma-api', '.' ]
  waitFor: ["-"]

# build web image
- name: 'gcr.io/cloud-builders/docker'
  id: "web-img"
  args: ['build', "-f", "Dockerfile.web",  "--build-arg=WEB_URL=${_WEB_URL}", "--build-arg=API_URL=${_API_URL}", "--build-arg=GQL_ENDPOINT=${_GQL_ENDPOINT}", "--build-arg=DATABASE_URL=${_DATABASE_URL}" ,"--build-arg=FIREBASE_API_KEY=${_FIREBASE_API_KEY}","--build-arg=FIREBASE_APP_ID=${_FIREBASE_APP_ID}","--build-arg=FIREBASE_AUTH_DOMAIN=${_FIREBASE_AUTH_DOMAIN}","--build-arg=FIREBASE_MESSAGING_SENDER_ID=${_FIREBASE_MESSAGING_SENDER_ID}","--build-arg=FIREBASE_PROJECT_ID=${_FIREBASE_PROJECT_ID}","--build-arg=FIREBASE_STORAGE_BUCKET=${_FIREBASE_STORAGE_BUCKET}","--build-arg=GOOGLE_MAP_ID=${_GOOGLE_MAP_ID}","--build-arg=GOOGLE_MAPS_API_KEY=${_GOOGLE_MAPS_API_KEY}","--build-arg=SESSION_SECRET=${_SESSION_SECRET}",'-t', 'gcr.io/${PROJECT_ID}/lma-web', '.']
  waitFor: ["-"]

# migrate db
- name: 'gcr.io/cloud-builders/yarn'
  id: "yarn-install"
  args: ["install"]

- name: 'gcr.io/cloud-builders/yarn'
  args: [  "rw", "prisma", "migrate", "deploy"]
  waitFor: ["api-img", "web-img"]

images: ['gcr.io/${PROJECT_ID}/lma-api',
 'gcr.io/${PROJECT_ID}/lma-web'
 ]

for the migrate step, i am getting this error in the cloud build build log:

Already have image (with digest): gcr.io/cloud-builders/yarn
/workspace/node_modules/@redwoodjs/cli/dist/index.js:62
cwd ??= process.env.RWJS_CWD;
    ^^^

SyntaxError: Unexpected token '??='
    at wrapSafe (internal/modules/cjs/loader.js:1001:16)
    at Module._compile (internal/modules/cjs/loader.js:1049:27)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
    at Module.load (internal/modules/cjs/loader.js:950:32)
    at Function.Module._load (internal/modules/cjs/loader.js:790:14)
    at Module.require (internal/modules/cjs/loader.js:974:19)
    at require (internal/modules/cjs/helpers.js:92:18)
    at Object.<anonymous> (/workspace/node_modules/@redwoodjs/core/dist/bins/redwood.js:30:1)
    at Module._compile (internal/modules/cjs/loader.js:1085:14)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)

( I commented out the other build steps for testing )

can anyone tell me why this is happening or how to fix this? it would be much appreciated, thanks in advance!

Hi @redwoodjsuser123 (awesome name btw!) RedwoodJS hasn’t had a dedicated Google Cloud deployment yet, namely for some of the api side function handling.

That said, I have seen this error before (actually reporting earlier this week but in local dev):

cwd ??= process.env.RWJS_CWD;

The ??= operator is only available in Node 15+. So, I would check to see if somehow you Node version I t=your deploy environment is 14 or lower.

See Node.js ES2015/ES6, ES2016 and ES2017 support for the versions where supported.

Note: RW will soon have improver Docker support as well so might make this easier to do.

Hi @redwoodjsuser123 (awesome name btw!)

haha thanks!

The ??= operator is only available in Node 15+. So, I would check to see if somehow you Node version I t=your deploy environment is 14 or lower.

thanks, this was really helpful.

I was able to make it work by using node instead of gcr.io/cloud-builders/yarn

new cloudbuild.yaml

steps:

# build api image
- name: 'gcr.io/cloud-builders/docker'
  id: "api-image"
  args: ["build", "-f", "Dockerfile.api",  "--build-arg=WEB_URL=${_WEB_URL}", "--build-arg=FIREBASE_PROJECT_ID=${_FIREBASE_PROJECT_ID}", "-t", 'gcr.io/${PROJECT_ID}/lma-api', '.' ]
  waitFor: ["-"]

# build web image
- name: 'gcr.io/cloud-builders/docker'
  id: "web-image"
  args: ['build', "-f", "Dockerfile.web",  "--build-arg=WEB_URL=${_WEB_URL}", "--build-arg=API_URL=${_API_URL}", "--build-arg=GQL_ENDPOINT=${_GQL_ENDPOINT}", "--build-arg=DATABASE_URL=${_DATABASE_URL}" ,"--build-arg=FIREBASE_API_KEY=${_FIREBASE_API_KEY}","--build-arg=FIREBASE_APP_ID=${_FIREBASE_APP_ID}","--build-arg=FIREBASE_AUTH_DOMAIN=${_FIREBASE_AUTH_DOMAIN}","--build-arg=FIREBASE_MESSAGING_SENDER_ID=${_FIREBASE_MESSAGING_SENDER_ID}","--build-arg=FIREBASE_PROJECT_ID=${_FIREBASE_PROJECT_ID}","--build-arg=FIREBASE_STORAGE_BUCKET=${_FIREBASE_STORAGE_BUCKET}","--build-arg=GOOGLE_MAP_ID=${_GOOGLE_MAP_ID}","--build-arg=GOOGLE_MAPS_API_KEY=${_GOOGLE_MAPS_API_KEY}","--build-arg=SESSION_SECRET=${_SESSION_SECRET}",'-t', 'gcr.io/${PROJECT_ID}/lma-web', '.']
  waitFor: ["-"]

# prepare dependencies for migrate command
- name: "node"
  id: "yarn-install"
  entrypoint: "yarn"
  args:
    - "install"
  waitFor: ["-"]

# migrate db
- name: "node"
  env: ["DATABASE_URL=$_DATABASE_URL"]
  entrypoint: "yarn"
  args: [ "rw", "prisma", "migrate", "deploy" ]
  waitFor: ["api-image", "web-image", "yarn-install"]

images: ['gcr.io/${PROJECT_ID}/lma-api', 'gcr.io/${PROJECT_ID}/lma-web']

Glad to help and == glad that it’s working. See what I did there? :slight_smile:

1 Like