通过Gitlab CI / CD将React JS APP部署到Heroku时出现应用程序错误

时间:2020-04-13 15:27:21

标签: reactjs heroku deployment gitlab

我创建了gitlab-ci.yml文件,该文件会将我的react应用程序部署到Heroku。这项工作正在通过,但我仍然收到HTTP STATUS 503:

应用程序错误:应用程序和页面中发生错误 无法送达。

这是我的gitlab-ci.yml文件:

image: node:12.13.1

before_script:
    - apt-get update -qy
    - apt-get install -y ruby-dev
    - gem install dpl

stages:
    - staging
    - production

staging:
    type: deploy
    stage: staging
    image: ruby:latest
    script:
        - dpl --provider=heroku --app=$HEROKU_APP_STAGING --api-key=$HEROKU_API_KEY
    only:
        - develop

production:
    type: deploy
    stage: production
    image: ruby:latest
    script:
        - dpl --provider=heroku --app=$HEROKU_APP_PRODUCTION --api-key=$HEROKU_API_KEY
    only:
        - master

作业日志:

Running with gitlab-runner 12.9.0 (4c96e5ad)
   on docker-auto-scale 72989761
Preparing the "docker+machine" executor
00:37
 Using Docker executor with image ruby:latest ...
 Pulling docker image ruby:latest ...
 Using docker image sha256:578602b0a84c6d5d5e3dd303ee5ebf3ecfd213fb904cb4b3c84538aaa88a9601 for ruby:latest ...
Preparing environment
00:03
 Running on runner-72989761-project-17866699-concurrent-0 via runner-72989761-srm-1586645060-84e4a08a...
Getting source from Git repository
00:01
 $ eval "$CI_PRE_CLONE_SCRIPT"
 Fetching changes with git depth set to 50...
 Initialized empty Git repository in /builds/apps/app-name/.git/
 Created fresh repository.
 From https://gitlab.com/apps/app-name
  * [new ref]         refs/pipelines/135060707 -> refs/pipelines/135060707
  * [new branch]      master                   -> origin/master
 Checking out b3ab6e5b as master...
 Skipping Git submodules setup
Restoring cache
00:02
Downloading artifacts
00:01
Running before_script and script
01:57
 $ apt-get update -qy
 Get:1 http://security.debian.org/debian-security buster/updates InRelease [65.4 kB]
 Get:2 http://deb.debian.org/debian buster InRelease [122 kB]
 Get:3 http://deb.debian.org/debian buster-updates InRelease [49.3 kB]
 Get:4 http://security.debian.org/debian-security buster/updates/main amd64 Packages [187 kB]
 Get:5 http://deb.debian.org/debian buster/main amd64 Packages [7907 kB]
 Get:6 http://deb.debian.org/debian buster-updates/main amd64 Packages [7380 B]
 Fetched 8337 kB in 2s (4002 kB/s)
 Reading package lists...
 $ apt-get install -y ruby-dev
 Reading package lists...
 Building dependency tree...
 Reading state information...
 The following additional packages will be installed:
   fonts-lato javascript-common libjs-jquery libruby2.5 rake ruby
   ruby-did-you-mean ruby-minitest ruby-net-telnet ruby-power-assert
   ruby-test-unit ruby-xmlrpc ruby2.5 ruby2.5-dev ruby2.5-doc
   rubygems-integration zip
 Suggested packages:
   apache2 | lighttpd | httpd ri bundler
 The following NEW packages will be installed:
   fonts-lato javascript-common libjs-jquery libruby2.5 rake ruby ruby-dev
   ruby-did-you-mean ruby-minitest ruby-net-telnet ruby-power-assert
   ruby-test-unit ruby-xmlrpc ruby2.5 ruby2.5-dev ruby2.5-doc
   rubygems-integration zip
 0 upgraded, 18 newly installed, 0 to remove and 5 not upgraded.
 Need to get 9954 kB of archives.
 After this operation, 49.3 MB of additional disk space will be used.
 Get:1 http://deb.debian.org/debian buster/main amd64 fonts-lato all 2.0-2 [2698 kB]
 Get:2 http://deb.debian.org/debian buster/main amd64 javascript-common all 11 [6120 B]
 Get:3 http://deb.debian.org/debian buster/main amd64 libjs-jquery all 3.3.1~dfsg-3 [332 kB]
 Get:4 http://deb.debian.org/debian buster/main amd64 rubygems-integration all 1.11 [4994 B]
 Get:5 http://deb.debian.org/debian buster/main amd64 ruby2.5 amd64 2.5.5-3+deb10u1 [400 kB]
 Get:6 http://deb.debian.org/debian buster/main amd64 ruby amd64 1:2.5.1 [11.3 kB]
 Get:7 http://deb.debian.org/debian buster/main amd64 rake all 12.3.1-3 [66.9 kB]
 Get:8 http://deb.debian.org/debian buster/main amd64 ruby-did-you-mean all 1.2.1-1 [14.4 kB]
 Get:9 http://deb.debian.org/debian buster/main amd64 ruby-minitest all 5.11.3-1 [54.8 kB]
 Get:10 http://deb.debian.org/debian buster/main amd64 ruby-net-telnet all 0.1.1-2 [12.5 kB]
 Get:11 http://deb.debian.org/debian buster/main amd64 ruby-power-assert all 1.1.1-1 [10.9 kB]
 Get:12 http://deb.debian.org/debian buster/main amd64 ruby-test-unit all 3.2.8-1 [72.4 kB]
 Get:13 http://deb.debian.org/debian buster/main amd64 ruby-xmlrpc all 0.3.0-2 [23.7 kB]
 Get:14 http://deb.debian.org/debian buster/main amd64 libruby2.5 amd64 2.5.5-3+deb10u1 [3438 kB]
 Get:15 http://deb.debian.org/debian buster/main amd64 ruby2.5-dev amd64 2.5.5-3+deb10u1 [415 kB]
 Get:16 http://deb.debian.org/debian buster/main amd64 ruby-dev amd64 1:2.5.1 [10.2 kB]
 Get:17 http://deb.debian.org/debian buster/main amd64 ruby2.5-doc all 2.5.5-3+deb10u1 [2149 kB]
 Get:18 http://deb.debian.org/debian buster/main amd64 zip amd64 3.0-11+b1 [234 kB]
 debconf: delaying package configuration, since apt-utils is not installed
 Fetched 9954 kB in 0s (37.9 MB/s)
 Selecting previously unselected package fonts-lato.
 (Reading database ... 23968 files and directories currently installed.)
 Preparing to unpack .../00-fonts-lato_2.0-2_all.deb ...
 Unpacking fonts-lato (2.0-2) ...
 Selecting previously unselected package javascript-common.
 Preparing to unpack .../01-javascript-common_11_all.deb ...
 Unpacking javascript-common (11) ...
 Selecting previously unselected package libjs-jquery.
 Preparing to unpack .../02-libjs-jquery_3.3.1~dfsg-3_all.deb ...
 Unpacking libjs-jquery (3.3.1~dfsg-3) ...
 Selecting previously unselected package rubygems-integration.
 Preparing to unpack .../03-rubygems-integration_1.11_all.deb ...
 Unpacking rubygems-integration (1.11) ...
 Selecting previously unselected package ruby2.5.
 Preparing to unpack .../04-ruby2.5_2.5.5-3+deb10u1_amd64.deb ...
 Unpacking ruby2.5 (2.5.5-3+deb10u1) ...
 Selecting previously unselected package ruby.
 Preparing to unpack .../05-ruby_1%3a2.5.1_amd64.deb ...
 Unpacking ruby (1:2.5.1) ...
 Selecting previously unselected package rake.
 Preparing to unpack .../06-rake_12.3.1-3_all.deb ...
 Unpacking rake (12.3.1-3) ...
 Selecting previously unselected package ruby-did-you-mean.
 Preparing to unpack .../07-ruby-did-you-mean_1.2.1-1_all.deb ...
 Unpacking ruby-did-you-mean (1.2.1-1) ...
 Selecting previously unselected package ruby-minitest.
 Preparing to unpack .../08-ruby-minitest_5.11.3-1_all.deb ...
 Unpacking ruby-minitest (5.11.3-1) ...
 Selecting previously unselected package ruby-net-telnet.
 Preparing to unpack .../09-ruby-net-telnet_0.1.1-2_all.deb ...
 Unpacking ruby-net-telnet (0.1.1-2) ...
 Selecting previously unselected package ruby-power-assert.
 Preparing to unpack .../10-ruby-power-assert_1.1.1-1_all.deb ...
 Unpacking ruby-power-assert (1.1.1-1) ...
 Selecting previously unselected package ruby-test-unit.
 Preparing to unpack .../11-ruby-test-unit_3.2.8-1_all.deb ...
 Unpacking ruby-test-unit (3.2.8-1) ...
 Selecting previously unselected package ruby-xmlrpc.
 Preparing to unpack .../12-ruby-xmlrpc_0.3.0-2_all.deb ...
 Unpacking ruby-xmlrpc (0.3.0-2) ...
 Selecting previously unselected package libruby2.5:amd64.
 Preparing to unpack .../13-libruby2.5_2.5.5-3+deb10u1_amd64.deb ...
 Unpacking libruby2.5:amd64 (2.5.5-3+deb10u1) ...
 Selecting previously unselected package ruby2.5-dev:amd64.
 Preparing to unpack .../14-ruby2.5-dev_2.5.5-3+deb10u1_amd64.deb ...
 Unpacking ruby2.5-dev:amd64 (2.5.5-3+deb10u1) ...
 Selecting previously unselected package ruby-dev:amd64.
 Preparing to unpack .../15-ruby-dev_1%3a2.5.1_amd64.deb ...
 Unpacking ruby-dev:amd64 (1:2.5.1) ...
 Selecting previously unselected package ruby2.5-doc.
 Preparing to unpack .../16-ruby2.5-doc_2.5.5-3+deb10u1_all.deb ...
 Unpacking ruby2.5-doc (2.5.5-3+deb10u1) ...
 Selecting previously unselected package zip.
 Preparing to unpack .../17-zip_3.0-11+b1_amd64.deb ...
 Unpacking zip (3.0-11+b1) ...
 Setting up javascript-common (11) ...
 Setting up fonts-lato (2.0-2) ...
 Setting up ruby-power-assert (1.1.1-1) ...
 Setting up rubygems-integration (1.11) ...
 Setting up ruby-minitest (5.11.3-1) ...
 Setting up zip (3.0-11+b1) ...
 Setting up ruby-test-unit (3.2.8-1) ...
 Setting up ruby-net-telnet (0.1.1-2) ...
 Setting up libjs-jquery (3.3.1~dfsg-3) ...
 Setting up ruby-did-you-mean (1.2.1-1) ...
 Setting up ruby-xmlrpc (0.3.0-2) ...
 Setting up ruby2.5-doc (2.5.5-3+deb10u1) ...
 Setting up ruby2.5 (2.5.5-3+deb10u1) ...
 Setting up ruby (1:2.5.1) ...
 Setting up rake (12.3.1-3) ...
 Setting up libruby2.5:amd64 (2.5.5-3+deb10u1) ...
 Setting up ruby2.5-dev:amd64 (2.5.5-3+deb10u1) ...
 Setting up ruby-dev:amd64 (1:2.5.1) ...
 Processing triggers for fontconfig (2.13.1-2) ...
 Processing triggers for libc-bin (2.28-10) ...
 $ gem install dpl
 Successfully installed dpl-1.10.15
 1 gem installed
 $ dpl --provider=heroku --app=$HEROKU_APP_PRODUCTION --api-key=$HEROKU_API_KEY
 Installing deploy dependencies
 Successfully installed multipart-post-2.1.1
 Successfully installed faraday-1.0.1
 Successfully installed rendezvous-0.1.3
 Successfully installed netrc-0.11.0
 Successfully installed dpl-heroku-1.10.15
 5 gems installed
 authentication succeeded
 checking for app app-name
 found app app-name
 Preparing deploy
 Cleaning up git repository with `git stash --all`. If you need build artifacts for deployment, set `deploy.skip_cleanup: true`. See https://docs.travis-ci.com/user/deployment#Uploading-Files-and-skip_cleanup.
 No local changes to save
 creating application archive
 Deploying application
 uploading application archive
 triggering new deployment
 -----> Node.js app detected

 -----> Creating runtime environment

        NPM_CONFIG_LOGLEVEL=error
        NODE_ENV=production
        NODE_MODULES_CACHE=true
        NODE_VERBOSE=false

 -----> Installing binaries
        engines.node (package.json):  unspecified
        engines.npm (package.json):   unspecified (use default)
        engines.yarn (package.json):  unspecified (use default)

        Resolving node version 12.x...
        Downloading and installing node 12.16.1...
        Using default npm version: 6.13.4
        Resolving yarn version 1.x...
        Downloading and installing yarn (1.22.4)...
        Installed yarn 1.22.4

 -----> Restoring cache
        - node_modules

 -----> Installing dependencies
        Installing node modules (yarn.lock)
        yarn install v1.22.4
        warning package.json: No license field
        warning app-name@0.1.0: No license field
        [1/4] Resolving packages...
        [2/4] Fetching packages...
        info fsevents@2.1.2: The platform "linux" is incompatible with this module.
        info "fsevents@2.1.2" is an optional dependency and failed compatibility check. Excluding it from installation.
        info fsevents@1.2.12: The platform "linux" is incompatible with this module.
        info "fsevents@1.2.12" is an optional dependency and failed compatibility check. Excluding it from installation.
        [3/4] Linking dependencies...
        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".
        [4/4] Building fresh packages...
        Done in 52.34s.

 -----> Build
        Running build (yarn)
        yarn run v1.22.4
 warning package.json: No license field
        $ react-scripts build
        Creating an optimized production build...
        Compiled successfully.

        File sizes after gzip:

          47.33 KB  build/static/js/2.659edb6d.chunk.js
          1.33 KB   build/static/js/main.348e3d03.chunk.js
          778 B     build/static/js/runtime-main.e4fbaa12.js
          520 B     build/static/css/main.7fbbdd52.chunk.css

        The project was built assuming it is hosted at /.
        You can control this with the homepage field in your package.json.

        The build folder is ready to be deployed.
        You may serve it with a static server:

          yarn global add serve
          serve -s build

        Find out more about deployment here:

          bit.ly/CRA-deploy

        Done in 10.53s.

 -----> Caching build
        - node_modules

 -----> Pruning devDependencies
        yarn install v1.22.4
        warning package.json: No license field
        warning app-name@0.1.0: No license field
        [1/4] Resolving packages...
        [2/4] Fetching packages...
        info fsevents@2.1.2: The platform "linux" is incompatible with this module.
        info "fsevents@2.1.2" is an optional dependency and failed compatibility check. Excluding it from installation.
        info fsevents@1.2.12: The platform "linux" is incompatible with this module.
        info "fsevents@1.2.12" is an optional dependency and failed compatibility check. Excluding it from installation.
        [3/4] Linking dependencies...
        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".
        [4/4] Building fresh packages...
        warning Ignored scripts due to flag.
        Done in 8.54s.

 -----> Build succeeded!
  !     Unmet dependencies don't fail yarn install but may cause runtime issues
        https://github.com/npm/npm/issues/7494
 -----> Discovering process types
        Procfile declares types     -> (none)
        Default types for buildpack -> web
 -----> Compressing...
        Done: 50M
 -----> Launching...
        Released v10
        https://app-name.herokuapp.com/ deployed to Heroku
 No stash entries found.
Running after_script
00:01
Saving cache
00:01
Uploading artifacts for successful job
00:02
 Job succeeded

Heroku构建日志:

-----> Node.js app detected

-----> Creating runtime environment

       NPM_CONFIG_LOGLEVEL=error
       NODE_ENV=production
       NODE_MODULES_CACHE=true
       NODE_VERBOSE=false

-----> Installing binaries
       engines.node (package.json):  unspecified
       engines.npm (package.json):   unspecified (use default)
       engines.yarn (package.json):  unspecified (use default)

       Resolving node version 12.x...
       Downloading and installing node 12.16.1...
       Using default npm version: 6.13.4
       Resolving yarn version 1.x...
       Downloading and installing yarn (1.22.4)...
       Installed yarn 1.22.4

-----> Restoring cache
       - node_modules

-----> Installing dependencies
       Installing node modules (yarn.lock)
       yarn install v1.22.4
       warning package.json: No license field
       warning app-name@0.1.0: No license field
       [1/4] Resolving packages...
       [2/4] Fetching packages...
       info fsevents@2.1.2: The platform "linux" is incompatible with this module.
       info "fsevents@2.1.2" is an optional dependency and failed compatibility check. Excluding it from installation.
       info fsevents@1.2.12: The platform "linux" is incompatible with this module.
       info "fsevents@1.2.12" is an optional dependency and failed compatibility check. Excluding it from installation.
       [3/4] Linking dependencies...
       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".
       [4/4] Building fresh packages...
       Done in 52.34s.

-----> Build
       Running build (yarn)
       yarn run v1.22.4
warning package.json: No license field
       $ react-scripts build
       Creating an optimized production build...
       Compiled successfully.

       File sizes after gzip:

         47.33 KB  build/static/js/2.659edb6d.chunk.js
         1.33 KB   build/static/js/main.348e3d03.chunk.js
         778 B     build/static/js/runtime-main.e4fbaa12.js
         520 B     build/static/css/main.7fbbdd52.chunk.css

       The project was built assuming it is hosted at /.
       You can control this with the homepage field in your package.json.

       The build folder is ready to be deployed.
       You may serve it with a static server:

         yarn global add serve
         serve -s build

       Find out more about deployment here:

         bit.ly/CRA-deploy

       Done in 10.53s.

-----> Caching build
       - node_modules

-----> Pruning devDependencies
       yarn install v1.22.4
       warning package.json: No license field
       warning app-name@0.1.0: No license field
       [1/4] Resolving packages...
       [2/4] Fetching packages...
       info fsevents@2.1.2: The platform "linux" is incompatible with this module.
       info "fsevents@2.1.2" is an optional dependency and failed compatibility check. Excluding it from installation.
       info fsevents@1.2.12: The platform "linux" is incompatible with this module.
       info "fsevents@1.2.12" is an optional dependency and failed compatibility check. Excluding it from installation.
       [3/4] Linking dependencies...
       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".
       [4/4] Building fresh packages...
       warning Ignored scripts due to flag.
       Done in 8.54s.

-----> Build succeeded!
 !     Unmet dependencies don't fail yarn install but may cause runtime issues
       https://github.com/npm/npm/issues/7494
-----> Discovering process types
       Procfile declares types     -> (none)
       Default types for buildpack -> web
-----> Compressing...
       Done: 50M
-----> Launching...
       Released v10
       https://app-name.herokuapp.com/ deployed to Heroku

Heroku日志

2020-04-13T15:19:47.960914+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=app-name.herokuapp.com request_id=4b2252a0-c333-4d38-96c0-88803af43130 fwd="35.157.32.153" dyno= connect= service= status=503 bytes= protocol=http

有人熟悉这个问题吗? 预先感谢

1 个答案:

答案 0 :(得分:-1)

H10表示“应用程序崩溃”。

https://devcenter.heroku.com/articles/error-codes#h10-app-crashed说:

Web dyno崩溃或Web dyno上的启动超时将显示此错误。

您为什么不检查Causes of Heroku H10-App Crashed Error And How To Solve Them来解决此错误的某些原因?