ローカルの環境では問題ないのですが,herokuでのデプロイがうまくいきません.
logにエラーが出ているのですが,エラーで検索をかけて調べtらのですが原因がよくわかりません.
解決策を教えていただけますと幸いです.
「このページは動作していません
アプリ名.herokuapp.comからデータが送信されませんでした。」
のページが出てしばらくしてから
「We're sorry, but something went wrong.
If you are the application owner check the logs for more information.
ERR_EMPTY_RESPONSE」
といったページになります.
その後ページを更新するとherokuのアプリケーションエラーのページになります.
(herokuのlogを見るとcode=H10 desc="App crashed"と出ている)
下記URLの動画を参考に行いました
「本番環境に公開しよう」のチャプターからです.
https://youtu.be/lZD1MIHwMBY
動画ではrails new
からすぐにデプロイしてますが,アプリの中身がある程度出来上がってからのデプロイです.
アドオン(無料)
heroku addons:create cleardb:ignite -a herokuアプリ名
[Dockerfile]
FROM ruby:2.6.6 ENV RAILS_ENV=production RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - \ && echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list \ && apt-get update -qq \ && apt-get install -y nodejs yarn WORKDIR /app COPY ./src /app RUN bundle config --local set path 'vendor/bundle' \ && bundle install COPY start.sh /start.sh RUN chmod 744 /start.sh CMD ["sh", "/start.sh"]
[docker-compose.yml]
version: '3' services: db: image: mysql:8.0 command: --default-authentication-plugin=mysql_native_password volumes: - ./src/db/mysql_data:/var/lib/mysql environment: MYSQL_ROOT_PASSWORD: password web: build: . command: bundle exec rails s -p 3000 -b '0.0.0.0' volumes: - ./src:/app ports: - "3000:3000" environment: RAILS_ENV: development depends_on: - db
[start.sh]
#!/bin/sh if [ "${RAILS_ENV}" = "production" ] then bundle exec rails assets:precompile fi bundle exec rails s -p ${PORT:-3000} -b 0.0.0.0
[database.yml]
default: &default adapter: mysql2 encoding: utf8mb4 pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %> username: root password: password host: db development: <<: *default database: app_development test: <<: *default database: app_test host: <%= ENV.fetch("APP_DATABASE_HOST") { 'db' } %> production: <<: *default database: <%= ENV['APP_DATABASE'] %> username: <%= ENV['APP_DATABASE_USERNAME'] %> password: <%= ENV['APP_DATABASE_PASSWORD'] %> host: <%= ENV['APP_DATABASE_HOST'] %>
log
. . . 2021-06-05T06:02:28.664495+00:00 app[web.1]: 2021-06-05T06:02:28.664495+00:00 app[web.1]: WARNING in asset size limit: The following asset(s) exceed the recommended size limit (244 KiB). 2021-06-05T06:02:28.664495+00:00 app[web.1]: This can impact web performance. 2021-06-05T06:02:28.664496+00:00 app[web.1]: Assets: 2021-06-05T06:02:28.664496+00:00 app[web.1]: js/application-bdaec03ed7599399b413.js (260 KiB) 2021-06-05T06:02:28.664496+00:00 app[web.1]: js/application-bdaec03ed7599399b413.js.map.gz (326 KiB) 2021-06-05T06:02:28.664497+00:00 app[web.1]: 2021-06-05T06:02:28.664506+00:00 app[web.1]: WARNING in entrypoint size limit: The following entrypoint(s) combined asset size exceeds the recommended limit (244 KiB). This can impact web performance. 2021-06-05T06:02:28.664507+00:00 app[web.1]: Entrypoints: 2021-06-05T06:02:28.664507+00:00 app[web.1]: application (260 KiB) 2021-06-05T06:02:28.664507+00:00 app[web.1]: js/application-bdaec03ed7599399b413.js 2021-06-05T06:02:28.664508+00:00 app[web.1]: 2021-06-05T06:02:28.664508+00:00 app[web.1]: 2021-06-05T06:02:28.664508+00:00 app[web.1]: WARNING in webpack performance recommendations: 2021-06-05T06:02:28.664509+00:00 app[web.1]: You can limit the size of your bundles by using import() or require.ensure to lazy load some parts of your application. 2021-06-05T06:02:28.664509+00:00 app[web.1]: For more info visit https://webpack.js.org/guides/code-splitting/ 2021-06-05T06:02:28.664510+00:00 app[web.1]: 2021-06-05T06:02:28.753952+00:00 heroku[web.1]: Stopping process with SIGKILL 2021-06-05T06:02:28.843316+00:00 heroku[web.1]: Process exited with status 137 2021-06-05T06:02:28.942027+00:00 heroku[web.1]: State changed from starting to crashed 2021-06-05T06:02:28.945822+00:00 heroku[web.1]: State changed from crashed to starting 2021-06-05T06:02:39.558378+00:00 heroku[router]: at=error code=H20 desc="App boot timeout" method=GET path="/" host=アプリ名.herokuapp.com request_id=bedeea2c-a9db-4ff3-b7f5-f8031a5550fe fwd="122.197.202.153" dyno= connect= service= status=503 bytes= protocol=https 2021-06-05T06:02:54.253017+00:00 heroku[web.1]: Starting process with command `sh /start.sh` 2021-06-05T06:03:02.452552+00:00 app[web.1]: yarn install v1.22.5 2021-06-05T06:03:02.659009+00:00 app[web.1]: [1/4] Resolving packages... 2021-06-05T06:03:03.606667+00:00 app[web.1]: [2/4] Fetching packages... 2021-06-05T06:03:20.894067+00:00 app[web.1]: info fsevents@2.3.2: The platform "linux" is incompatible with this module. 2021-06-05T06:03:20.894324+00:00 app[web.1]: info "fsevents@2.3.2" is an optional dependency and failed compatibility check. Excluding it from installation. 2021-06-05T06:03:20.919615+00:00 app[web.1]: info fsevents@1.2.13: The platform "linux" is incompatible with this module. 2021-06-05T06:03:20.919748+00:00 app[web.1]: info "fsevents@1.2.13" is an optional dependency and failed compatibility check. Excluding it from installation. 2021-06-05T06:03:20.932630+00:00 app[web.1]: [3/4] Linking dependencies... 2021-06-05T06:03:30.406048+00:00 app[web.1]: [4/4] Building fresh packages... 2021-06-05T06:03:31.766540+00:00 app[web.1]: Done in 29.33s. . . . 2021-06-05T06:03:32.978674+00:00 app[web.1]: Compiling... 2021-06-05T06:03:41.248584+00:00 heroku[router]: at=error code=H20 desc="App boot timeout" method=GET path="/" host=アプリ名.herokuapp.com request_id=85dade92-0e17-42b9-a26f-6a22334c31ee fwd="122.197.202.153" dyno= connect= service= status=503 bytes= protocol=https 2021-06-05T06:03:59.221143+00:00 app[web.1]: Compiled all packs in /app/public/packs . . . 2021-06-05T06:03:59.221512+00:00 app[web.1]: WARNING in asset size limit: The following asset(s) exceed the recommended size limit (244 KiB). 2021-06-05T06:03:59.221512+00:00 app[web.1]: This can impact web performance. 2021-06-05T06:03:59.221512+00:00 app[web.1]: Assets: 2021-06-05T06:03:59.221512+00:00 app[web.1]: js/application-bdaec03ed7599399b413.js (260 KiB) 2021-06-05T06:03:59.221513+00:00 app[web.1]: js/application-bdaec03ed7599399b413.js.map.gz (326 KiB) 2021-06-05T06:03:59.221513+00:00 app[web.1]: 2021-06-05T06:03:59.221515+00:00 app[web.1]: WARNING in entrypoint size limit: The following entrypoint(s) combined asset size exceeds the recommended limit (244 KiB). This can impact web performance. 2021-06-05T06:03:59.221515+00:00 app[web.1]: Entrypoints: 2021-06-05T06:03:59.221516+00:00 app[web.1]: application (260 KiB) 2021-06-05T06:03:59.221516+00:00 app[web.1]: js/application-bdaec03ed7599399b413.js 2021-06-05T06:03:59.221516+00:00 app[web.1]: 2021-06-05T06:03:59.221516+00:00 app[web.1]: 2021-06-05T06:03:59.221516+00:00 app[web.1]: WARNING in webpack performance recommendations: 2021-06-05T06:03:59.221517+00:00 app[web.1]: You can limit the size of your bundles by using import() or require.ensure to lazy load some parts of your application. 2021-06-05T06:03:59.221517+00:00 app[web.1]: For more info visit https://webpack.js.org/guides/code-splitting/ 2021-06-05T06:03:59.221517+00:00 app[web.1]: 2021-06-05T06:04:03.717770+00:00 app[web.1]: => Booting Puma 2021-06-05T06:04:03.717792+00:00 app[web.1]: => Rails 6.1.3.2 application starting in production 2021-06-05T06:04:03.717793+00:00 app[web.1]: => Run `bin/rails server --help` for more startup options 2021-06-05T06:04:05.905056+00:00 app[web.1]: Puma starting in single mode... 2021-06-05T06:04:05.905070+00:00 app[web.1]: * Puma version: 5.3.2 (ruby 2.6.6-p146) ("Sweetnighter") 2021-06-05T06:04:05.905071+00:00 app[web.1]: * Min threads: 5 2021-06-05T06:04:05.905071+00:00 app[web.1]: * Max threads: 5 2021-06-05T06:04:05.905072+00:00 app[web.1]: * Environment: production 2021-06-05T06:04:05.905072+00:00 app[web.1]: * PID: 125 2021-06-05T06:04:05.905316+00:00 app[web.1]: * Listening on http://0.0.0.0:48883 2021-06-05T06:04:05.908428+00:00 app[web.1]: Use Ctrl-C to stop 2021-06-05T06:04:06.303237+00:00 heroku[web.1]: State changed from starting to up 2021-06-05T06:04:07.617338+00:00 heroku[router]: at=info method=GET path="/" host=アプリ名.herokuapp.com request_id=cbfe72ff-1878-4539-927f-4d4d8f99657d fwd="122.197.202.153" dyno=web.1 connect=0ms service=23ms status=500 bytes=1827 protocol=https
あなたの回答
tips
プレビュー