Error: Cannot find module '/app/__sapper__/build' on Cloud Build

GrepThis

I'm trying to setup an automated Cloud Build for a sapper project that gets deployed to Cloud Run. However I'm getting an error on the deploy. This is my first attempt at CI work flow so I'm sure there are multiple things I'm doing wrong.

cloudbuild.yaml

steps:
  - name: "gcr.io/cloud-builders/gcloud"
    args:
      - kms
      - decrypt
      - --ciphertext-file=.env.enc
      - --plaintext-file=.env
      - --location=global
      - --keyring=jointcreative
      - --key=cloudbuild-env

  - name: "gcr.io/cloud-builders/docker"
    args: ["build", "-t", "gcr.io/$PROJECT_ID/$PROJECT_ID", "."]

  - name: "gcr.io/cloud-builders/docker"
    args: ["push", "gcr.io/$PROJECT_ID/$PROJECT_ID"]

  - name: "gcr.io/cloud-builders/npm"
    args: ["ci", "--production"]

  - name: 'gcr.io/cloud-builders/gcloud'
    args:
    - 'run'
    - 'deploy'
    - 'jointcreative'
    - '--image'
    - 'gcr.io/$PROJECT_ID/$PROJECT_ID'
    - '--region'
    - 'us-central1'
    - '--platform'
    - 'managed'

  - name: "gcr.io/$PROJECT_ID/firebase"
    args: ['deploy']

Dockerfile

FROM mhart/alpine-node:12


WORKDIR /app
COPY package.json package-lock.json ./
RUN npm ci --production

FROM mhart/alpine-node:slim-12

WORKDIR /app
COPY --from=0 /app .
COPY . .

ENV PORT 8080
ENV HOST 0.0.0.0

EXPOSE 8080
CMD ["node", "__sapper__/build"]

Error logs enter image description here

Mike Nikles

The reason you get this error is because you don't build the Sapper application with npm run build.

I published a repository with Sapper deployed to Cloud Run a few minutes ago on Github at https://github.com/mikenikles/sapper-on-cloud-run.

The Dockerfile I use is based on 3 stages to minimize the final image size.

# This stage builds the sapper application.
FROM mhart/alpine-node:12 AS build-app
WORKDIR /app
COPY . .
RUN npm install --no-audit --unsafe-perm
RUN npm run build

# This stage installs the runtime dependencies.
FROM mhart/alpine-node:12 AS build-runtime
WORKDIR /app
COPY package.json package-lock.json ./
RUN npm ci --production --unsafe-perm

# This stage only needs the compiled Sapper application
# and the runtime dependencies.
FROM mhart/alpine-node:slim-12
WORKDIR /app
COPY --from=build-app /app/__sapper__ ./__sapper__
COPY --from=build-app /app/static ./static
COPY --from=build-runtime /app/node_modules ./node_modules

EXPOSE 3000
CMD ["node", "__sapper__/build"]

I also recommend the following .dockerignore file to copy only what is necessary for Sapper to run:

/*
!/package.json
!/package-lock.json
!/rollup.config.js
!/src
!/static

In your cloudbuild.yaml, you may want to consider adding the following to the Cloud Run deploy script if you plan on exposing the service publicly:

  - 'managed'
  - '--allow-unauthenticated'

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Error [ERR_MODULE_NOT_FOUND]: Cannot find module 'build\app' imported from build\server.js

From Dev

Module build failed: Error: Cannot find module 'node-sass'

From Dev

ng build cannot find module

From Dev

Cordova 4.3.0 - build command returns error Cannot find module 'Q'

From Dev

Error: Cannot find module '../build/Release/bson' on Mac

From Dev

Ionic build error Cannot find module './scheduler/Action'

From Dev

GCP App Engine and Cloud Build: Cannot find module '/workspace/server.js'

From Dev

ERROR in ./src/styles.scss .. Module build failed: Error: Cannot find module 'node-sass'

From Dev

Typescript React / NestJS app fails @Heroku build - "error TS2307: Cannot find module"

From Dev

Rocket.Chat build failing with error "Cannot find module '../build/Release/sharp.node' "

From Dev

webpacker Uncaught Error: Module build failed / Cannot find module 'babel-plugin-syntax-dynamic-import'

From Dev

Cannot find module '../build/Release/bson'. NodeJS

From Dev

Cannot find Module "build" in Docker Container

From Dev

travis cannot build because Error: Cannot find module 'react-test-renderer/shallow'

From Dev

Build:Cannot find module OurFirstAppWithFVisualStudio.module.scss

From Dev

NG Build fail in Azure DevOps pipline : Error: Cannot find module '../internal/operators/audit'

From Dev

Ionic build cannot find module error. How to import Android plugin?

From Dev

react) 'npm run build' is not working. and I got this message " Error: Cannot find module 'jsonfile/utils'"

From Dev

Error: Cannot find module 'firebase/app' When deploying google cloud function

From Dev

Error: "Cannot find module" while running firebase cloud function

From Dev

Deploying to Firestore Cloud Functions - "Error: cannot find module"

From Dev

IBM cloud : Cannot build app

From Dev

Build error : Cannot find getter for field

From Dev

gcc build error : cannot find -lssl

From Dev

Error: Cannot find module './'

From Dev

ERROR in ./src/app.js Module build failed (from ./node_modules/babel-loader/lib/index.js): Error: Cannot find module '@babel/preset-present-env'

From Dev

Error: Cannot find module './App' at webpackMissingModule

From Dev

Error: Cannot find module 'app/MyComponent/MyComponent.module' Error: Cannot find module

From Dev

Cordova 8.1.1 android build: cannot find module xcode

Related Related

  1. 1

    Error [ERR_MODULE_NOT_FOUND]: Cannot find module 'build\app' imported from build\server.js

  2. 2

    Module build failed: Error: Cannot find module 'node-sass'

  3. 3

    ng build cannot find module

  4. 4

    Cordova 4.3.0 - build command returns error Cannot find module 'Q'

  5. 5

    Error: Cannot find module '../build/Release/bson' on Mac

  6. 6

    Ionic build error Cannot find module './scheduler/Action'

  7. 7

    GCP App Engine and Cloud Build: Cannot find module '/workspace/server.js'

  8. 8

    ERROR in ./src/styles.scss .. Module build failed: Error: Cannot find module 'node-sass'

  9. 9

    Typescript React / NestJS app fails @Heroku build - "error TS2307: Cannot find module"

  10. 10

    Rocket.Chat build failing with error "Cannot find module '../build/Release/sharp.node' "

  11. 11

    webpacker Uncaught Error: Module build failed / Cannot find module 'babel-plugin-syntax-dynamic-import'

  12. 12

    Cannot find module '../build/Release/bson'. NodeJS

  13. 13

    Cannot find Module "build" in Docker Container

  14. 14

    travis cannot build because Error: Cannot find module 'react-test-renderer/shallow'

  15. 15

    Build:Cannot find module OurFirstAppWithFVisualStudio.module.scss

  16. 16

    NG Build fail in Azure DevOps pipline : Error: Cannot find module '../internal/operators/audit'

  17. 17

    Ionic build cannot find module error. How to import Android plugin?

  18. 18

    react) 'npm run build' is not working. and I got this message " Error: Cannot find module 'jsonfile/utils'"

  19. 19

    Error: Cannot find module 'firebase/app' When deploying google cloud function

  20. 20

    Error: "Cannot find module" while running firebase cloud function

  21. 21

    Deploying to Firestore Cloud Functions - "Error: cannot find module"

  22. 22

    IBM cloud : Cannot build app

  23. 23

    Build error : Cannot find getter for field

  24. 24

    gcc build error : cannot find -lssl

  25. 25

    Error: Cannot find module './'

  26. 26

    ERROR in ./src/app.js Module build failed (from ./node_modules/babel-loader/lib/index.js): Error: Cannot find module '@babel/preset-present-env'

  27. 27

    Error: Cannot find module './App' at webpackMissingModule

  28. 28

    Error: Cannot find module 'app/MyComponent/MyComponent.module' Error: Cannot find module

  29. 29

    Cordova 8.1.1 android build: cannot find module xcode

HotTag

Archive