Javascript Can';t从Google应用程序引擎内部构建React应用程序

Javascript Can';t从Google应用程序引擎内部构建React应用程序,javascript,node.js,reactjs,google-app-engine,Javascript,Node.js,Reactjs,Google App Engine,我正在尝试在GAE上部署后构建我的React应用程序,也就是说,通过将以下启动脚本放入我的package.json “开始”:“反应脚本生成” …但我似乎无法建造 此外,我看到的每个教程都提到在部署到GAE之前先构建它。为什么它不在部署后构建 mypackage.json 我的app.yaml文件 runtime: nodejs10 instance_class: F2 env_variables: POSTGRES_HOST: /cloudsql/development-omix-pla

我正在尝试在GAE上部署后构建我的React应用程序,也就是说,通过将以下启动脚本放入我的
package.json

“开始”:“反应脚本生成”

…但我似乎无法建造

此外,我看到的每个教程都提到在部署到GAE之前先构建它。为什么它不在部署后构建

mypackage.json

我的app.yaml文件

runtime: nodejs10
instance_class: F2

env_variables:
  POSTGRES_HOST: /cloudsql/development-omix-platform:europe-west2:omixplatform
  INSTANCE_CONNECTION_NAME: development-omix-platform:europe-west2:omixplatform
  PORT: 8080
  DEBUG: graphile-build-pg
  FIREBASE_SERVICE_ACCOUNT_JSON_FILE_NAME: firebase-service-account.json

handlers:
  - url: /
    static_files: build/index.html
    upload: build/index.html

  - url: /api/.*
    script: auto

  - url: /graphql
    script: auto

  - url: /graphiql
    script: auto

  - url: /__postgraphql/.*
    script: auto

  - url: /(.*\..*)$
    static_files: client/\1
    upload: client/(.*)

  - url: /(.*)
    static_files: client/index.html
    upload: client/index.html
我希望为部署的新版本创建一个build文件夹,但实际情况并非如此`

以下是GAE的日志:

Updated my package.json to reflect correctly.I am using react-scripts build as the start script.Here is the log from the deployment: ````[
  {
    "protoPayload": {
      "@type": "type.googleapis.com/google.cloud.audit.AuditLog",
      "status": {},
      "authenticationInfo": {
        "principalEmail": "siddiquisarik@gmail.com"
      },
      "requestMetadata": {
        "callerIp": "27.7.91.59",
        "callerSuppliedUserAgent": "google-cloud-sdk x_Tw5K8nnjoRAqULM9PFAC2b gcloud/257.0.0 command/gcloud.app.deploy invocation-id/3a31d2254493473dabd0906852ba7b57 environment/None environment-version/None interactive/True from-script/False python/2.7.13 term/ (Windows NT 10.0.17134),gzip(gfe)",
        "requestAttributes": {},
        "destinationAttributes": {}
      },
      "serviceName": "appengine.googleapis.com",
      "methodName": "google.appengine.v1.Versions.CreateVersion",
      "authorizationInfo": [
        {
          "resource": "apps/emaily-dev-229719/services/default/versions/20190808t113803",
          "permission": "appengine.versions.create",
          "granted": true,
          "resourceAttributes": {}
        }
      ],
      "resourceName": "apps/emaily-dev-229719/services/default/versions/20190808t113803",
      "serviceData": {
        "@type": "type.googleapis.com/google.appengine.v1.AuditData",
        "createVersion": {
          "request": {
            "parent": "apps/emaily-dev-229719/services/default",
            "version": {
              "id": "20190808t113803",
              "instanceClass": "F2",
              "runtime": "nodejs10",
              "envVariables": {
                "DEBUG": "graphile-build-pg",
                "FIREBASE_SERVICE_ACCOUNT_JSON_FILE_NAME": "firebase-service-account.json",
                "INSTANCE_CONNECTION_NAME": "development-omix-platform:europe-west2:omixplatform",
                "PORT": "8080",
                "POSTGRES_HOST": "/cloudsql/development-omix-platform:europe-west2:omixplatform"
              },
              "entrypoint": {
                "shell": ""
              }
            }
          }
        }
      },
      "resourceLocation": {
        "currentLocations": [
          "asia-south1"
        ]
      }
    },
    "insertId": "-f8xiere12hkk",
    "resource": {
      "type": "gae_app",
      "labels": {
        "version_id": "20190808t113803",
        "module_id": "default",
        "project_id": "emaily-dev-229719"
      }
    },
    "timestamp": "2019-08-08T06:08:11.156Z",
    "severity": "NOTICE",
    "logName": "projects/emaily-dev-229719/logs/cloudaudit.googleapis.com%2Factivity",
    "operation": {
      "id": "6b80dc4e-070d-4eea-99fe-0e22a25815a8",
      "producer": "appengine.googleapis.com/admin",
      "first": true
    },
    "receiveTimestamp": "2019-08-08T06:08:13.784603661Z"
  },
  {
    "protoPayload": {
      "@type": "type.googleapis.com/google.cloud.audit.AuditLog",
      "authenticationInfo": {
        "principalEmail": "siddiquisarik@gmail.com"
      },
      "requestMetadata": {
        "requestAttributes": {},
        "destinationAttributes": {}
      },
      "serviceName": "appengine.googleapis.com",
      "methodName": "google.appengine.v1.Versions.CreateVersion",
      "resourceName": "apps/emaily-dev-229719/services/default/versions/20190808t113803",
      "resourceLocation": {
        "currentLocations": [
          "asia-south1"
        ]
      }
    },
    "insertId": "-6dlv9vdh0gm",
    "resource": {
      "type": "gae_app",
      "labels": {
        "project_id": "emaily-dev-229719",
        "version_id": "20190808t113803",
        "module_id": "default"
      }
    },
    "timestamp": "2019-08-08T06:09:45.201Z",
    "severity": "NOTICE",
    "logName": "projects/emaily-dev-229719/logs/cloudaudit.googleapis.com%2Factivity",
    "operation": {
      "id": "6b80dc4e-070d-4eea-99fe-0e22a25815a8",
      "producer": "appengine.googleapis.com/admin",
      "last": true
    },
    "receiveTimestamp": "2019-08-08T06:09:45.476924659Z"
  }
]
添加生成日志

starting build "0efe9d27-d864-455a-8319-2ddab8300544"

FETCHSOURCE
BUILD
Starting Step #0 - "fetcher"
Step #0 - "fetcher": Already have image (with digest): gcr.io/cloud-builders/gcs-fetcher
Step #0 - "fetcher": Fetching manifest gs://staging.emaily-dev-229719.appspot.com/ae/6b80dc4e-070d-4eea-99fe-0e22a25815a8/manifest.json.
Step #0 - "fetcher": Processing 14 files.
Step #0 - "fetcher": ******************************************************
Step #0 - "fetcher": Status: SUCCESS
Step #0 - "fetcher": Started: 2019-08-08T06:08:21Z
Step #0 - "fetcher": Completed: 2019-08-08T06:08:23Z
Step #0 - "fetcher": Requested workers: 200
Step #0 - "fetcher": Actual workers: 14
Step #0 - "fetcher": Total files: 14
Step #0 - "fetcher": Total retries: 0
Step #0 - "fetcher": GCS timeouts: 0
Step #0 - "fetcher": MiB downloaded: 0.44 MiB
Step #0 - "fetcher": MiB/s throughput: 0.26 MiB/s
Step #0 - "fetcher": Time for manifest: 899.39 ms
Step #0 - "fetcher": Total time: 2.59 s
Step #0 - "fetcher": ******************************************************
Finished Step #0 - "fetcher"
Starting Step #1 - "builder"
Step #1 - "builder": Pulling image: gcr.io/gae-runtimes/nodejs10_app_builder:nodejs10_20190602_10_16_0_RC00
Step #1 - "builder": nodejs10_20190602_10_16_0_RC00: Pulling from gae-runtimes/nodejs10_app_builder
Step #1 - "builder": Digest: sha256:8d016fee32b529f5e7083ad2c4e4d8f26b9b47d35db7102e3569791bcbb737ce
Step #1 - "builder": Status: Downloaded newer image for gcr.io/gae-runtimes/nodejs10_app_builder:nodejs10_20190602_10_16_0_RC00
Step #1 - "builder": 2019/08/08 06:08:26 Starting commonbuild with args [commonbuild --runtime=nodejs10 --entrypoint= --src=/workspace --config-file=/.gaeconfig/app_start.json -- ftl.par --name=asia.gcr.io/emaily-dev-229719/app-engine-tmp/app/ttl-2h:6b80dc4e-070d-4eea-99fe-0e22a25815a8 --directory=/workspace --destination=/srv --cache-repository=asia.gcr.io/emaily-dev-229719/app-engine-tmp/build-cache/ttl-7d --cache --additional-directory=/.gaeconfig --builder-output-path="" --base=asia.gcr.io/gae-runtimes/nodejs10:nodejs10_20190602_10_16_0_RC00].
Step #1 - "builder": 2019/08/08 06:08:26 No start command generator found for nodejs10, using default app start command "serve".
Step #1 - "builder": 2019/08/08 06:08:26 Writing configuration file "/.gaeconfig/app_start.json".
Step #1 - "builder": 2019/08/08 06:08:26 Invoking build command "ftl.par --name=asia.gcr.io/emaily-dev-229719/app-engine-tmp/app/ttl-2h:6b80dc4e-070d-4eea-99fe-0e22a25815a8 --directory=/workspace --destination=/srv --cache-repository=asia.gcr.io/emaily-dev-229719/app-engine-tmp/build-cache/ttl-7d --cache --additional-directory=/.gaeconfig --builder-output-path=\"\" --base=asia.gcr.io/gae-runtimes/nodejs10:nodejs10_20190602_10_16_0_RC00".
Step #1 - "builder": INFO FTL version node-v0.17.0
Step #1 - "builder": INFO Beginning FTL build for node
Step #1 - "builder": INFO FTL arg passed: exposed_ports None
Step #1 - "builder": INFO FTL arg passed: cache_repository asia.gcr.io/emaily-dev-229719/app-engine-tmp/build-cache/ttl-7d
Step #1 - "builder": INFO FTL arg passed: tar_base_image_path None
Step #1 - "builder": INFO FTL arg passed: export_cache_stats False
Step #1 - "builder": INFO FTL arg passed: builder_output_path ""
Step #1 - "builder": INFO FTL arg passed: name asia.gcr.io/emaily-dev-229719/app-engine-tmp/app/ttl-2h:6b80dc4e-070d-4eea-99fe-0e22a25815a8
Step #1 - "builder": INFO FTL arg passed: ttl 168
Step #1 - "builder": INFO FTL arg passed: global_cache False
Step #1 - "builder": INFO FTL arg passed: cache True
Step #1 - "builder": INFO FTL arg passed: upload True
Step #1 - "builder": INFO FTL arg passed: sh_c_prefix False
Step #1 - "builder": INFO FTL arg passed: fail_on_error True
Step #1 - "builder": INFO FTL arg passed: base asia.gcr.io/gae-runtimes/nodejs10:nodejs10_20190602_10_16_0_RC00
Step #1 - "builder": INFO FTL arg passed: output_path None
Step #1 - "builder": INFO FTL arg passed: cache_key_version v0.17.0
Step #1 - "builder": INFO FTL arg passed: cache_salt 
Step #1 - "builder": INFO FTL arg passed: directory /workspace
Step #1 - "builder": INFO FTL arg passed: entrypoint None
Step #1 - "builder": INFO FTL arg passed: additional_directory /.gaeconfig
Step #1 - "builder": INFO FTL arg passed: destination_path /srv
Step #1 - "builder": INFO FTL arg passed: verbosity NOTSET
Step #1 - "builder": INFO starting: full build
Step #1 - "builder": INFO starting: builder initialization
Step #1 - "builder": INFO Loading Docker credentials for repository 'asia.gcr.io/gae-runtimes/nodejs10:nodejs10_20190602_10_16_0_RC00'
Step #1 - "builder": INFO Loading Docker credentials for repository 'asia.gcr.io/emaily-dev-229719/app-engine-tmp/app/ttl-2h:6b80dc4e-070d-4eea-99fe-0e22a25815a8'
Step #1 - "builder": INFO builder initialization took 0 seconds
Step #1 - "builder": INFO starting: build process for FTL image
Step #1 - "builder": INFO starting: rm_node_modules
Step #1 - "builder": INFO rm_node_modules rm -rf /workspace/node_modules
Step #1 - "builder": INFO `rm_node_modules` stdout:
Step #1 - "builder": 
Step #1 - "builder": INFO rm_node_modules took 0 seconds
Step #1 - "builder": INFO using descriptor:yarn.lock
Step #1 - "builder": INFO using descriptor:package.json
Step #1 - "builder": INFO starting: checking_cached_packages_json_layer
Step #1 - "builder": DEBUG Checking cache for cache_key 2664c8e15d525a968e27ebe3bb094ddf40e661d41a9043edaf265ec95c055d29
Step #1 - "builder": INFO No cached base image found for entry: asia.gcr.io/emaily-dev-229719/app-engine-tmp/build-cache/ttl-7d/node-cache:2664c8e15d525a968e27ebe3bb094ddf40e661d41a9043edaf265ec95c055d29.
Step #1 - "builder": INFO Cache miss on local cache for asia.gcr.io/emaily-dev-229719/app-engine-tmp/build-cache/ttl-7d/node-cache:2664c8e15d525a968e27ebe3bb094ddf40e661d41a9043edaf265ec95c055d29
Step #1 - "builder": INFO No cached dependency layer for 2664c8e15d525a968e27ebe3bb094ddf40e661d41a9043edaf265ec95c055d29
Step #1 - "builder": INFO [CACHE][MISS] v0.17.0:NODE->2664c8e15d525a968e27ebe3bb094ddf40e661d41a9043edaf265ec95c055d29
Step #1 - "builder": INFO checking_cached_packages_json_layer took 0 seconds
Step #1 - "builder": INFO starting: building_packages_json_layer
Step #1 - "builder": INFO starting: yarn_install
Step #1 - "builder": INFO yarn_install yarn install --production
Step #1 - "builder": INFO `yarn_install` stdout:
Step #1 - "builder": yarn install v1.9.4
Step #1 - "builder": [1/4] Resolving packages...
Step #1 - "builder": [2/4] Fetching packages...
Step #1 - "builder": info fsevents@2.0.6: The platform "linux" is incompatible with this module.
Step #1 - "builder": info "fsevents@2.0.6" is an optional dependency and failed compatibility check. Excluding it from installation.
Step #1 - "builder": info fsevents@1.2.9: The platform "linux" is incompatible with this module.
Step #1 - "builder": info "fsevents@1.2.9" is an optional dependency and failed compatibility check. Excluding it from installation.
Step #1 - "builder": [3/4] Linking dependencies...
Step #1 - "builder": [4/4] Building fresh packages...
Step #1 - "builder": Done in 38.66s.
Step #1 - "builder": 
Step #1 - "builder": INFO `yarn_install` had stderr output:
Step #1 - "builder": warning "react-scripts > @typescript-eslint/eslint-plugin@1.6.0" has unmet peer dependency "typescript@*".
Step #1 - "builder": warning "react-scripts > @typescript-eslint/parser@1.6.0" has unmet peer dependency "typescript@*".
Step #1 - "builder": warning "react-scripts > ts-pnp@1.1.2" has unmet peer dependency "typescript@*".
Step #1 - "builder": warning "react-scripts > @typescript-eslint/eslint-plugin > @typescript-eslint/typescript-estree@1.6.0" has unmet peer dependency "typescript@*".
Step #1 - "builder": warning "react-scripts > @typescript-eslint/eslint-plugin > tsutils@3.17.1" has unmet peer dependency "typescript@>=2.8.0 || >= 3.2.0-dev || >= 3.3.0-dev || >= 3.4.0-dev || >= 3.5.0-dev || >= 3.6.0-dev || >= 3.6.0-beta || >= 3.7.0-dev || >= 3.7.0-beta".
Step #1 - "builder": 
Step #1 - "builder": INFO yarn_install took 39 seconds
Step #1 - "builder": INFO starting: tar_runtime_package
Step #1 - "builder": INFO tar_runtime_package tar -pcf /tmp/tmp14UUYM.tar --hard-dereference --transform flags=r;s,^,/srv/node_modules/, --exclude *.pyc .
Step #1 - "builder": INFO `tar_runtime_package` stdout:
Step #1 - "builder": 
Step #1 - "builder": INFO tar_runtime_package took 0 seconds
Step #1 - "builder": INFO starting: gzip_tar_runtime_package
Step #1 - "builder": INFO gzip_tar_runtime_package gzip /tmp/tmp14UUYM.tar -1
Step #1 - "builder": INFO `gzip_tar_runtime_package` stdout:
Step #1 - "builder": 
Step #1 - "builder": INFO gzip_tar_runtime_package took 2 seconds
Step #1 - "builder": INFO starting: rm_node_modules
Step #1 - "builder": INFO rm_node_modules rm -rf /workspace/node_modules
Step #1 - "builder": INFO `rm_node_modules` stdout:
Step #1 - "builder": 
Step #1 - "builder": INFO rm_node_modules took 0 seconds
Step #1 - "builder": INFO building_packages_json_layer took 43 seconds
Step #1 - "builder": INFO starting: uploading_packages_json_layer
Step #1 - "builder": INFO Layer sha256:770e78845ef75d41d0555b936a55cbecf2073d003fe4811284ef44d31054bbd1 pushed.
Step #1 - "builder": INFO Layer sha256:f341002bd84f37c2963472ebebea9d3c90ac6e2627b3fde7377a87e9f3e83c69 pushed.
Step #1 - "builder": INFO Finished upload of: asia.gcr.io/emaily-dev-229719/app-engine-tmp/build-cache/ttl-7d/node-cache:2664c8e15d525a968e27ebe3bb094ddf40e661d41a9043edaf265ec95c055d29
Step #1 - "builder": INFO uploading_packages_json_layer took 8 seconds
Step #1 - "builder": INFO starting: Building app layer
Step #1 - "builder": INFO starting: tar_runtime_package
Step #1 - "builder": INFO tar_runtime_package tar -pcf /tmp/tmp46oxw8.tar --hard-dereference --transform flags=r;s,^,/srv/, --exclude *.pyc .
Step #1 - "builder": INFO `tar_runtime_package` stdout:
Step #1 - "builder": 
Step #1 - "builder": INFO tar_runtime_package took 0 seconds
Step #1 - "builder": INFO starting: gzip_tar_runtime_package
Step #1 - "builder": INFO gzip_tar_runtime_package gzip /tmp/tmp46oxw8.tar -1
Step #1 - "builder": INFO `gzip_tar_runtime_package` stdout:
Step #1 - "builder": 
Step #1 - "builder": INFO gzip_tar_runtime_package took 0 seconds
Step #1 - "builder": INFO Finished gzipping tarfile.
Step #1 - "builder": INFO Building app layer took 0 seconds
Step #1 - "builder": INFO starting: Building app layer
Step #1 - "builder": INFO starting: tar_runtime_package
Step #1 - "builder": INFO tar_runtime_package tar -pcf /tmp/tmphzX880.tar --hard-dereference --transform flags=r;s,^,/.gaeconfig/, --exclude *.pyc .
Step #1 - "builder": INFO `tar_runtime_package` stdout:
Step #1 - "builder": 
Step #1 - "builder": INFO tar_runtime_package took 0 seconds
Step #1 - "builder": INFO starting: gzip_tar_runtime_package
Step #1 - "builder": INFO gzip_tar_runtime_package gzip /tmp/tmphzX880.tar -1
Step #1 - "builder": INFO `gzip_tar_runtime_package` stdout:
Step #1 - "builder": 
Step #1 - "builder": INFO gzip_tar_runtime_package took 0 seconds
Step #1 - "builder": INFO Finished gzipping tarfile.
Step #1 - "builder": INFO Building app layer took 0 seconds
Step #1 - "builder": INFO starting: Stitching layers into final image
Step #1 - "builder": INFO Stitching layers into final image took 0 seconds
Step #1 - "builder": INFO starting: Uploading final image
Step #1 - "builder": INFO starting: Pushing image to Docker registry
Step #1 - "builder": INFO Pushing final image...
Step #1 - "builder": INFO Layer sha256:f341002bd84f37c2963472ebebea9d3c90ac6e2627b3fde7377a87e9f3e83c69 exists, skipping
Step #1 - "builder": INFO Layer sha256:3c2cba919283a210665e480bcbf943eaaf4ed87a83f02e81bb286b8bdead0e75 exists, skipping
Step #1 - "builder": INFO Layer sha256:75c5cf2a0cfac9f36b9eff671bfb135c9e893bd126e3f1ca29880e094b71ef59 exists, skipping
Step #1 - "builder": INFO Layer sha256:517783fc8820a78d42a17058fb41d300464b2f57666b79b263b71473ce0add58 exists, skipping
Step #1 - "builder": INFO Layer sha256:3e6140238cb96ed591571804c4abc9935a800ddcc6661a89dda9d3917ae90f7a exists, skipping
Step #1 - "builder": INFO Layer sha256:992de7a46af205f308bbbe2a0438b371a5ab9bb1d367cad03c86dd3a34ee7442 exists, skipping
Step #1 - "builder": INFO Layer sha256:49e24c87983c8a9441263a3ae58c98691a0b0d228e7af0414a39d78638a10451 exists, skipping
Step #1 - "builder": INFO Layer sha256:4f083d4df15f0671110e16e80efc7d410e316f9f3ca549d4c532551b21a4fbde exists, skipping
Step #1 - "builder": INFO Layer sha256:deabf7bad5e7feeee5b21092bd193ecbd1b227d1fe1eae287fddb10c952e9e35 exists, skipping
Step #1 - "builder": INFO Layer sha256:729a2199e385e7c3b1d473adb6ad74f888d88537f3cb5fba50a2223e528f2af1 exists, skipping
Step #1 - "builder": INFO Layer sha256:c06ebd05b949f8c382380fa7b6cb45b9b39a9ca25ba3eb819803a9b5e08b8798 exists, skipping
Step #1 - "builder": INFO Layer sha256:a1fe0bd3e83030687176951a74a2bdfba3de9f032bf371412e9a9b0d646fe087 exists, skipping
Step #1 - "builder": INFO Layer sha256:3aed06531a572af8cda05edf7544b27c4d48572df65831e051c4cebdbdd7f253 mounted.
Step #1 - "builder": INFO Layer sha256:3aed06531a572af8cda05edf7544b27c4d48572df65831e051c4cebdbdd7f253 pushed.
Step #1 - "builder": INFO Layer sha256:ead752f81c3ec2c2a6ac6692c4c9df2e5e1389552ed0b79a48e2d595d122b8fa mounted.
Step #1 - "builder": INFO Layer sha256:ead752f81c3ec2c2a6ac6692c4c9df2e5e1389552ed0b79a48e2d595d122b8fa pushed.
Step #1 - "builder": INFO Layer sha256:0ab6231c1a046e6afdf063797ef9e7bec7b6f2bf0a706b673ece2ecbe49ba425 mounted.
Step #1 - "builder": INFO Layer sha256:0ab6231c1a046e6afdf063797ef9e7bec7b6f2bf0a706b673ece2ecbe49ba425 pushed.
Step #1 - "builder": INFO Layer sha256:6d78a22a5429819bb4c7c261fa2c8921ea24fc61c83f0ee58739112f660382e7 pushed.
Step #1 - "builder": INFO Layer sha256:e728a177ac564e7d9c355d434ce03da7f13874250554ef01186916a09fed9137 pushed.
Step #1 - "builder": INFO Layer sha256:20043117973e6f614d9ba35565716932fba47fecdcf13bc378b26c5de29ed6dd pushed.
Step #1 - "builder": INFO Finished upload of: asia.gcr.io/emaily-dev-229719/app-engine-tmp/app/ttl-2h:6b80dc4e-070d-4eea-99fe-0e22a25815a8
Step #1 - "builder": INFO Pushing image to Docker registry took 5 seconds
Step #1 - "builder": INFO Uploading final image took 5 seconds
Step #1 - "builder": INFO build process for FTL image took 59 seconds
Step #1 - "builder": INFO full build took 59 seconds
Finished Step #1 - "builder"
PUSH
DONE

以前提交的材料 对于独立的React应用程序,您不必在部署到Google App Engine标准之前进行构建。只要在本地运行
npm start
,只要app.yaml存在且有效,您就可以按项目[1]的原样运行
gcloud app deploy

也就是说,在部署之前,您需要在本地运行
npm run script build
,并且package.json中的“start”脚本应保持为
react scripts start

您还可以看看这篇文章[2],它解决了一个与您类似的问题

[1]

[2]

你能分享你的
GAE的日志吗?
?嗨,更新了my package.json以正确反映。我使用react scripts build作为开始脚本。添加了部署中的日志:@sarik123,你有没有找到这个问题的根源?我也面临同样的问题,如果能听到你的解决方案,我将不胜感激……谢谢@JKleinne……事实上,我已经阅读了这些教程,我的问题可能不是最实际的问题……但是由于GAE默认运行npm开始脚本,如果npm启动脚本包含build命令,那么它不应该创建build文件夹。如果你查看上面提到的帖子,它们是先构建,然后再从那里提供服务。我有一个简单的问题,我们可以在部署到GAE后进行构建吗(这似乎没有发生)然后从应用程序引擎标准的内部过程启动应用程序,不幸的是,这是内部过程,因此我们无法确定是否发出了
npm start
命令来启动应用程序,或者它是否直接运行
react scripts start
。但是,使用App Engine Flex可以通过指定
运行时:nodejs\n env:Flex
运行时:自定义>/code>来观察到这一点。在指定自定义运行时,无论您是使用Google提供的Node.js映像还是您自己的Dockerfile,Flex环境都会使用Dockerfile。我鼓励您尝试在Flex环境中使用nodejs运行时部署基本HelloWorld应用程序,并注意其中一个构建步骤将包含
CMD npmstart
因此事实上,GAE不会从package.json运行start脚本……docker容器会运行。如果您决定在自定义运行时创建自己的Dockerfile,您可以修改这些构建步骤,以便在部署时生成React.js产品,并通过Dockerfile的配置使其全部可用。我将编辑我的答案,以包括一个示例Dockerfile,您可以将其用于特定情况:部署时,创建一个production React.js构建和服务。
starting build "0efe9d27-d864-455a-8319-2ddab8300544"

FETCHSOURCE
BUILD
Starting Step #0 - "fetcher"
Step #0 - "fetcher": Already have image (with digest): gcr.io/cloud-builders/gcs-fetcher
Step #0 - "fetcher": Fetching manifest gs://staging.emaily-dev-229719.appspot.com/ae/6b80dc4e-070d-4eea-99fe-0e22a25815a8/manifest.json.
Step #0 - "fetcher": Processing 14 files.
Step #0 - "fetcher": ******************************************************
Step #0 - "fetcher": Status: SUCCESS
Step #0 - "fetcher": Started: 2019-08-08T06:08:21Z
Step #0 - "fetcher": Completed: 2019-08-08T06:08:23Z
Step #0 - "fetcher": Requested workers: 200
Step #0 - "fetcher": Actual workers: 14
Step #0 - "fetcher": Total files: 14
Step #0 - "fetcher": Total retries: 0
Step #0 - "fetcher": GCS timeouts: 0
Step #0 - "fetcher": MiB downloaded: 0.44 MiB
Step #0 - "fetcher": MiB/s throughput: 0.26 MiB/s
Step #0 - "fetcher": Time for manifest: 899.39 ms
Step #0 - "fetcher": Total time: 2.59 s
Step #0 - "fetcher": ******************************************************
Finished Step #0 - "fetcher"
Starting Step #1 - "builder"
Step #1 - "builder": Pulling image: gcr.io/gae-runtimes/nodejs10_app_builder:nodejs10_20190602_10_16_0_RC00
Step #1 - "builder": nodejs10_20190602_10_16_0_RC00: Pulling from gae-runtimes/nodejs10_app_builder
Step #1 - "builder": Digest: sha256:8d016fee32b529f5e7083ad2c4e4d8f26b9b47d35db7102e3569791bcbb737ce
Step #1 - "builder": Status: Downloaded newer image for gcr.io/gae-runtimes/nodejs10_app_builder:nodejs10_20190602_10_16_0_RC00
Step #1 - "builder": 2019/08/08 06:08:26 Starting commonbuild with args [commonbuild --runtime=nodejs10 --entrypoint= --src=/workspace --config-file=/.gaeconfig/app_start.json -- ftl.par --name=asia.gcr.io/emaily-dev-229719/app-engine-tmp/app/ttl-2h:6b80dc4e-070d-4eea-99fe-0e22a25815a8 --directory=/workspace --destination=/srv --cache-repository=asia.gcr.io/emaily-dev-229719/app-engine-tmp/build-cache/ttl-7d --cache --additional-directory=/.gaeconfig --builder-output-path="" --base=asia.gcr.io/gae-runtimes/nodejs10:nodejs10_20190602_10_16_0_RC00].
Step #1 - "builder": 2019/08/08 06:08:26 No start command generator found for nodejs10, using default app start command "serve".
Step #1 - "builder": 2019/08/08 06:08:26 Writing configuration file "/.gaeconfig/app_start.json".
Step #1 - "builder": 2019/08/08 06:08:26 Invoking build command "ftl.par --name=asia.gcr.io/emaily-dev-229719/app-engine-tmp/app/ttl-2h:6b80dc4e-070d-4eea-99fe-0e22a25815a8 --directory=/workspace --destination=/srv --cache-repository=asia.gcr.io/emaily-dev-229719/app-engine-tmp/build-cache/ttl-7d --cache --additional-directory=/.gaeconfig --builder-output-path=\"\" --base=asia.gcr.io/gae-runtimes/nodejs10:nodejs10_20190602_10_16_0_RC00".
Step #1 - "builder": INFO FTL version node-v0.17.0
Step #1 - "builder": INFO Beginning FTL build for node
Step #1 - "builder": INFO FTL arg passed: exposed_ports None
Step #1 - "builder": INFO FTL arg passed: cache_repository asia.gcr.io/emaily-dev-229719/app-engine-tmp/build-cache/ttl-7d
Step #1 - "builder": INFO FTL arg passed: tar_base_image_path None
Step #1 - "builder": INFO FTL arg passed: export_cache_stats False
Step #1 - "builder": INFO FTL arg passed: builder_output_path ""
Step #1 - "builder": INFO FTL arg passed: name asia.gcr.io/emaily-dev-229719/app-engine-tmp/app/ttl-2h:6b80dc4e-070d-4eea-99fe-0e22a25815a8
Step #1 - "builder": INFO FTL arg passed: ttl 168
Step #1 - "builder": INFO FTL arg passed: global_cache False
Step #1 - "builder": INFO FTL arg passed: cache True
Step #1 - "builder": INFO FTL arg passed: upload True
Step #1 - "builder": INFO FTL arg passed: sh_c_prefix False
Step #1 - "builder": INFO FTL arg passed: fail_on_error True
Step #1 - "builder": INFO FTL arg passed: base asia.gcr.io/gae-runtimes/nodejs10:nodejs10_20190602_10_16_0_RC00
Step #1 - "builder": INFO FTL arg passed: output_path None
Step #1 - "builder": INFO FTL arg passed: cache_key_version v0.17.0
Step #1 - "builder": INFO FTL arg passed: cache_salt 
Step #1 - "builder": INFO FTL arg passed: directory /workspace
Step #1 - "builder": INFO FTL arg passed: entrypoint None
Step #1 - "builder": INFO FTL arg passed: additional_directory /.gaeconfig
Step #1 - "builder": INFO FTL arg passed: destination_path /srv
Step #1 - "builder": INFO FTL arg passed: verbosity NOTSET
Step #1 - "builder": INFO starting: full build
Step #1 - "builder": INFO starting: builder initialization
Step #1 - "builder": INFO Loading Docker credentials for repository 'asia.gcr.io/gae-runtimes/nodejs10:nodejs10_20190602_10_16_0_RC00'
Step #1 - "builder": INFO Loading Docker credentials for repository 'asia.gcr.io/emaily-dev-229719/app-engine-tmp/app/ttl-2h:6b80dc4e-070d-4eea-99fe-0e22a25815a8'
Step #1 - "builder": INFO builder initialization took 0 seconds
Step #1 - "builder": INFO starting: build process for FTL image
Step #1 - "builder": INFO starting: rm_node_modules
Step #1 - "builder": INFO rm_node_modules rm -rf /workspace/node_modules
Step #1 - "builder": INFO `rm_node_modules` stdout:
Step #1 - "builder": 
Step #1 - "builder": INFO rm_node_modules took 0 seconds
Step #1 - "builder": INFO using descriptor:yarn.lock
Step #1 - "builder": INFO using descriptor:package.json
Step #1 - "builder": INFO starting: checking_cached_packages_json_layer
Step #1 - "builder": DEBUG Checking cache for cache_key 2664c8e15d525a968e27ebe3bb094ddf40e661d41a9043edaf265ec95c055d29
Step #1 - "builder": INFO No cached base image found for entry: asia.gcr.io/emaily-dev-229719/app-engine-tmp/build-cache/ttl-7d/node-cache:2664c8e15d525a968e27ebe3bb094ddf40e661d41a9043edaf265ec95c055d29.
Step #1 - "builder": INFO Cache miss on local cache for asia.gcr.io/emaily-dev-229719/app-engine-tmp/build-cache/ttl-7d/node-cache:2664c8e15d525a968e27ebe3bb094ddf40e661d41a9043edaf265ec95c055d29
Step #1 - "builder": INFO No cached dependency layer for 2664c8e15d525a968e27ebe3bb094ddf40e661d41a9043edaf265ec95c055d29
Step #1 - "builder": INFO [CACHE][MISS] v0.17.0:NODE->2664c8e15d525a968e27ebe3bb094ddf40e661d41a9043edaf265ec95c055d29
Step #1 - "builder": INFO checking_cached_packages_json_layer took 0 seconds
Step #1 - "builder": INFO starting: building_packages_json_layer
Step #1 - "builder": INFO starting: yarn_install
Step #1 - "builder": INFO yarn_install yarn install --production
Step #1 - "builder": INFO `yarn_install` stdout:
Step #1 - "builder": yarn install v1.9.4
Step #1 - "builder": [1/4] Resolving packages...
Step #1 - "builder": [2/4] Fetching packages...
Step #1 - "builder": info fsevents@2.0.6: The platform "linux" is incompatible with this module.
Step #1 - "builder": info "fsevents@2.0.6" is an optional dependency and failed compatibility check. Excluding it from installation.
Step #1 - "builder": info fsevents@1.2.9: The platform "linux" is incompatible with this module.
Step #1 - "builder": info "fsevents@1.2.9" is an optional dependency and failed compatibility check. Excluding it from installation.
Step #1 - "builder": [3/4] Linking dependencies...
Step #1 - "builder": [4/4] Building fresh packages...
Step #1 - "builder": Done in 38.66s.
Step #1 - "builder": 
Step #1 - "builder": INFO `yarn_install` had stderr output:
Step #1 - "builder": warning "react-scripts > @typescript-eslint/eslint-plugin@1.6.0" has unmet peer dependency "typescript@*".
Step #1 - "builder": warning "react-scripts > @typescript-eslint/parser@1.6.0" has unmet peer dependency "typescript@*".
Step #1 - "builder": warning "react-scripts > ts-pnp@1.1.2" has unmet peer dependency "typescript@*".
Step #1 - "builder": warning "react-scripts > @typescript-eslint/eslint-plugin > @typescript-eslint/typescript-estree@1.6.0" has unmet peer dependency "typescript@*".
Step #1 - "builder": warning "react-scripts > @typescript-eslint/eslint-plugin > tsutils@3.17.1" has unmet peer dependency "typescript@>=2.8.0 || >= 3.2.0-dev || >= 3.3.0-dev || >= 3.4.0-dev || >= 3.5.0-dev || >= 3.6.0-dev || >= 3.6.0-beta || >= 3.7.0-dev || >= 3.7.0-beta".
Step #1 - "builder": 
Step #1 - "builder": INFO yarn_install took 39 seconds
Step #1 - "builder": INFO starting: tar_runtime_package
Step #1 - "builder": INFO tar_runtime_package tar -pcf /tmp/tmp14UUYM.tar --hard-dereference --transform flags=r;s,^,/srv/node_modules/, --exclude *.pyc .
Step #1 - "builder": INFO `tar_runtime_package` stdout:
Step #1 - "builder": 
Step #1 - "builder": INFO tar_runtime_package took 0 seconds
Step #1 - "builder": INFO starting: gzip_tar_runtime_package
Step #1 - "builder": INFO gzip_tar_runtime_package gzip /tmp/tmp14UUYM.tar -1
Step #1 - "builder": INFO `gzip_tar_runtime_package` stdout:
Step #1 - "builder": 
Step #1 - "builder": INFO gzip_tar_runtime_package took 2 seconds
Step #1 - "builder": INFO starting: rm_node_modules
Step #1 - "builder": INFO rm_node_modules rm -rf /workspace/node_modules
Step #1 - "builder": INFO `rm_node_modules` stdout:
Step #1 - "builder": 
Step #1 - "builder": INFO rm_node_modules took 0 seconds
Step #1 - "builder": INFO building_packages_json_layer took 43 seconds
Step #1 - "builder": INFO starting: uploading_packages_json_layer
Step #1 - "builder": INFO Layer sha256:770e78845ef75d41d0555b936a55cbecf2073d003fe4811284ef44d31054bbd1 pushed.
Step #1 - "builder": INFO Layer sha256:f341002bd84f37c2963472ebebea9d3c90ac6e2627b3fde7377a87e9f3e83c69 pushed.
Step #1 - "builder": INFO Finished upload of: asia.gcr.io/emaily-dev-229719/app-engine-tmp/build-cache/ttl-7d/node-cache:2664c8e15d525a968e27ebe3bb094ddf40e661d41a9043edaf265ec95c055d29
Step #1 - "builder": INFO uploading_packages_json_layer took 8 seconds
Step #1 - "builder": INFO starting: Building app layer
Step #1 - "builder": INFO starting: tar_runtime_package
Step #1 - "builder": INFO tar_runtime_package tar -pcf /tmp/tmp46oxw8.tar --hard-dereference --transform flags=r;s,^,/srv/, --exclude *.pyc .
Step #1 - "builder": INFO `tar_runtime_package` stdout:
Step #1 - "builder": 
Step #1 - "builder": INFO tar_runtime_package took 0 seconds
Step #1 - "builder": INFO starting: gzip_tar_runtime_package
Step #1 - "builder": INFO gzip_tar_runtime_package gzip /tmp/tmp46oxw8.tar -1
Step #1 - "builder": INFO `gzip_tar_runtime_package` stdout:
Step #1 - "builder": 
Step #1 - "builder": INFO gzip_tar_runtime_package took 0 seconds
Step #1 - "builder": INFO Finished gzipping tarfile.
Step #1 - "builder": INFO Building app layer took 0 seconds
Step #1 - "builder": INFO starting: Building app layer
Step #1 - "builder": INFO starting: tar_runtime_package
Step #1 - "builder": INFO tar_runtime_package tar -pcf /tmp/tmphzX880.tar --hard-dereference --transform flags=r;s,^,/.gaeconfig/, --exclude *.pyc .
Step #1 - "builder": INFO `tar_runtime_package` stdout:
Step #1 - "builder": 
Step #1 - "builder": INFO tar_runtime_package took 0 seconds
Step #1 - "builder": INFO starting: gzip_tar_runtime_package
Step #1 - "builder": INFO gzip_tar_runtime_package gzip /tmp/tmphzX880.tar -1
Step #1 - "builder": INFO `gzip_tar_runtime_package` stdout:
Step #1 - "builder": 
Step #1 - "builder": INFO gzip_tar_runtime_package took 0 seconds
Step #1 - "builder": INFO Finished gzipping tarfile.
Step #1 - "builder": INFO Building app layer took 0 seconds
Step #1 - "builder": INFO starting: Stitching layers into final image
Step #1 - "builder": INFO Stitching layers into final image took 0 seconds
Step #1 - "builder": INFO starting: Uploading final image
Step #1 - "builder": INFO starting: Pushing image to Docker registry
Step #1 - "builder": INFO Pushing final image...
Step #1 - "builder": INFO Layer sha256:f341002bd84f37c2963472ebebea9d3c90ac6e2627b3fde7377a87e9f3e83c69 exists, skipping
Step #1 - "builder": INFO Layer sha256:3c2cba919283a210665e480bcbf943eaaf4ed87a83f02e81bb286b8bdead0e75 exists, skipping
Step #1 - "builder": INFO Layer sha256:75c5cf2a0cfac9f36b9eff671bfb135c9e893bd126e3f1ca29880e094b71ef59 exists, skipping
Step #1 - "builder": INFO Layer sha256:517783fc8820a78d42a17058fb41d300464b2f57666b79b263b71473ce0add58 exists, skipping
Step #1 - "builder": INFO Layer sha256:3e6140238cb96ed591571804c4abc9935a800ddcc6661a89dda9d3917ae90f7a exists, skipping
Step #1 - "builder": INFO Layer sha256:992de7a46af205f308bbbe2a0438b371a5ab9bb1d367cad03c86dd3a34ee7442 exists, skipping
Step #1 - "builder": INFO Layer sha256:49e24c87983c8a9441263a3ae58c98691a0b0d228e7af0414a39d78638a10451 exists, skipping
Step #1 - "builder": INFO Layer sha256:4f083d4df15f0671110e16e80efc7d410e316f9f3ca549d4c532551b21a4fbde exists, skipping
Step #1 - "builder": INFO Layer sha256:deabf7bad5e7feeee5b21092bd193ecbd1b227d1fe1eae287fddb10c952e9e35 exists, skipping
Step #1 - "builder": INFO Layer sha256:729a2199e385e7c3b1d473adb6ad74f888d88537f3cb5fba50a2223e528f2af1 exists, skipping
Step #1 - "builder": INFO Layer sha256:c06ebd05b949f8c382380fa7b6cb45b9b39a9ca25ba3eb819803a9b5e08b8798 exists, skipping
Step #1 - "builder": INFO Layer sha256:a1fe0bd3e83030687176951a74a2bdfba3de9f032bf371412e9a9b0d646fe087 exists, skipping
Step #1 - "builder": INFO Layer sha256:3aed06531a572af8cda05edf7544b27c4d48572df65831e051c4cebdbdd7f253 mounted.
Step #1 - "builder": INFO Layer sha256:3aed06531a572af8cda05edf7544b27c4d48572df65831e051c4cebdbdd7f253 pushed.
Step #1 - "builder": INFO Layer sha256:ead752f81c3ec2c2a6ac6692c4c9df2e5e1389552ed0b79a48e2d595d122b8fa mounted.
Step #1 - "builder": INFO Layer sha256:ead752f81c3ec2c2a6ac6692c4c9df2e5e1389552ed0b79a48e2d595d122b8fa pushed.
Step #1 - "builder": INFO Layer sha256:0ab6231c1a046e6afdf063797ef9e7bec7b6f2bf0a706b673ece2ecbe49ba425 mounted.
Step #1 - "builder": INFO Layer sha256:0ab6231c1a046e6afdf063797ef9e7bec7b6f2bf0a706b673ece2ecbe49ba425 pushed.
Step #1 - "builder": INFO Layer sha256:6d78a22a5429819bb4c7c261fa2c8921ea24fc61c83f0ee58739112f660382e7 pushed.
Step #1 - "builder": INFO Layer sha256:e728a177ac564e7d9c355d434ce03da7f13874250554ef01186916a09fed9137 pushed.
Step #1 - "builder": INFO Layer sha256:20043117973e6f614d9ba35565716932fba47fecdcf13bc378b26c5de29ed6dd pushed.
Step #1 - "builder": INFO Finished upload of: asia.gcr.io/emaily-dev-229719/app-engine-tmp/app/ttl-2h:6b80dc4e-070d-4eea-99fe-0e22a25815a8
Step #1 - "builder": INFO Pushing image to Docker registry took 5 seconds
Step #1 - "builder": INFO Uploading final image took 5 seconds
Step #1 - "builder": INFO build process for FTL image took 59 seconds
Step #1 - "builder": INFO full build took 59 seconds
Finished Step #1 - "builder"
PUSH
DONE
# Dockerfile extending the generic Node image with application files for a
# single application.
FROM gcr.io/google_appengine/nodejs
COPY . /app/
# You have to specify "--unsafe-perm" with npm install
# when running as root.  Failing to do this can cause
# install to appear to succeed even if a preinstall
# script fails, and may have other adverse consequences
# as well.
# This command will also cat the npm-debug.log file after the
# build, if it exists.
RUN npm install --unsafe-perm || \
  ((if [ -f npm-debug.log ]; then \
      cat npm-debug.log; \
    fi) && false)
RUN npm install -g serve
RUN npm run-script build
CMD serve -s build