Dokku 上的 Create-react-app 部署失败

Create-react-app deployment failure on Dokku

我正在尝试部署通过 Create-react-app to my Dokku on DigitalOcean thank to this heroku buildpacks 制作的全新 React 应用程序。按照他们的指示,最终失败了...

=====> Downloading Buildpack: https://github.com/heroku/heroku-buildpack-static.git
=====> Detected Framework: Static HTML
remote:   % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
remote:                                  Dload  Upload   Total   Spent    Left  Speed
remote: 100  838k  100  838k    0     0   514k      0  0:00:01  0:00:01 --:--:--  514k
-----> Installed directory to /app/bin
       Using release configuration from last framework (Static HTML).
remote: cat: /tmp/build/last_pack_release.out: input file is output file
--- {}
-----> Discovering process types
       Procfile declares types ->
-----> Releasing justpushit-app (dokku/justpushit-app:latest)...
-----> Deploying justpushit-app (dokku/justpushit-app:latest)...
-----> Attempting to run scripts.dokku.predeploy from app.json (if defined)
-----> App Procfile file found (/home/dokku/justpushit-app/DOKKU_PROCFILE)
-----> DOKKU_SCALE file found (/home/dokku/justpushit-app/DOKKU_SCALE)
=====> web=1
-----> Attempting pre-flight checks
       For more efficient zero downtime deployments, create a file CHECKS.
       See http://dokku.viewdocs.io/dokku/deployment/zero-downtime-deploys/ for examples
       CHECKS file not found in container: Running simple container check...
-----> Waiting for 10 seconds ...
remote: App container failed to start!!
=====> justpushit-app web container output:
       Injecting runtime env into /app/build/static/js/main.060925d8.js (from .profile.d/inject_react_app_env.sh)
       setuidgid: usage: setuidgid account child
=====> end justpushit-app web container output
To pantouflesdokku:justpushit-app
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'dokku@pantouflesdokku:justpushit-app'

似乎一切正常,但应用程序从未启动。我在这里错过了什么?

解决方案相当简单。整个构建工作正常,但必须以某种方式初始化应用程序。

我添加了一个Procfile并在里面写了下面一行...

web: npm start

希望对您有所帮助。

因为我有同样的问题,所以我为这个特定的构建包打开了一个问题:https://github.com/mars/create-react-app-buildpack/issues/54 幸运的是它的维护者非常友好地为我提供了正确的 Procfile 内容。

要解决此问题,您应该有一个 Procfile,其中包含以下行:

web: bin/boot

而不是 web: npm start 这不会生成完整的开发服务器。因此,您的服务器 memory/cpu 使用起来应该容易得多。