現在Railsを使ったWebアプリケーションを作成しており、デプロイ先をHerokuにしようと考えています。
実際に自動デプロイをさせてみたところCircleCI上で確認する限り成功しているようなのですが、サイトを開くとApplication Errorが発生します。(アプリ名は my-example-app に書き換えています。)
% heroku logs -t -a my-example-app
としたところこのようなログが出ます。
ログ(最後の一部)
2021-07-04T21:20:57.132061+00:00 app[web.1]: Entrypoint application = js/application-12f04455053704825e8e.js js/application-12f04455053704825e8e.js.map 2021-07-04T21:20:57.132061+00:00 app[web.1]: [0] (webpack)/buildin/module.js 552 bytes {0} [built] 2021-07-04T21:20:57.132062+00:00 app[web.1]: [4] ./app/javascript/packs/application.js 480 bytes {0} [built] 2021-07-04T21:20:57.132062+00:00 app[web.1]: [5] ./app/javascript/channels/index.js 205 bytes {0} [built] 2021-07-04T21:20:57.132063+00:00 app[web.1]: [6] ./app/javascript/channels sync _channel.js$ 160 bytes {0} [built] 2021-07-04T21:20:57.132063+00:00 app[web.1]: + 3 hidden modules 2021-07-04T21:20:57.132063+00:00 app[web.1]: 2021-07-04T21:20:57.161094+00:00 app[web.1]: PORT 54992 2021-07-04T21:20:59.756500+00:00 app[web.1]: => Booting Puma 2021-07-04T21:20:59.756510+00:00 app[web.1]: => Rails 6.1.3.2 application starting in production 2021-07-04T21:20:59.756510+00:00 app[web.1]: => Run `bin/rails server --help` for more startup options 2021-07-04T21:21:01.292564+00:00 app[web.1]: Puma starting in single mode... 2021-07-04T21:21:01.292638+00:00 app[web.1]: * Puma version: 5.3.2 (ruby 3.0.1-p64) ("Sweetnighter") 2021-07-04T21:21:01.292702+00:00 app[web.1]: * Min threads: 5 2021-07-04T21:21:01.292737+00:00 app[web.1]: * Max threads: 5 2021-07-04T21:21:01.292778+00:00 app[web.1]: * Environment: production 2021-07-04T21:21:01.292819+00:00 app[web.1]: * PID: 132 2021-07-04T21:21:01.293340+00:00 app[web.1]: * Listening on http://0.0.0.0:3000 2021-07-04T21:21:01.298449+00:00 app[web.1]: Use Ctrl-C to stop 2021-07-04T21:21:33.839795+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 120 seconds of launch 2021-07-04T21:21:33.901675+00:00 heroku[web.1]: Stopping process with SIGKILL 2021-07-04T21:21:34.003261+00:00 heroku[web.1]: Process exited with status 137 2021-07-04T21:21:34.075055+00:00 heroku[web.1]: State changed from starting to crashed 2021-07-04T21:21:35.648343+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=my-example-app.herokuapp.com request_id=cc678261-d6f0-456e-a8eb-15b19c38718c fwd="14.10.48.193" dyno= connect= service= status=503 bytes= protocol=https
関連していると思われるファイル
.circleci/config.yml
version: 2.1 orbs: ruby: circleci/ruby@1.1.3 heroku: circleci/heroku@1.2.3 node: circleci/node@4.4.0 jobs: build: docker: - image: circleci/ruby:3.0 working_directory: ~/my-example-app/src steps: - checkout: path: ~/my-example-app - run: name: bundleにプラットフォームをx86_64-linuxとするよう指定 command: bundle lock --add-platform x86_64-linux - ruby/install-deps test: docker: - image: circleci/ruby:3.0 - image: circleci/mysql:5.5 environment: MYSQL_ROOT_PASSWORD: password MYSQL_DATABASE: app_test MYSQL_USER: root environment: BUNDLE_JOBS: "3" BUNDLE_RETRY: "3" APP_DATABASE_HOST: "127.0.0.1" RAILS_ENV: test working_directory: ~/my-example-app/src steps: - checkout: path: ~/my-example-app - run: name: bundleにプラットフォームをx86_64-linuxとするよう指定 command: bundle lock --add-platform x86_64-linux - ruby/install-deps - node/install: install-yarn: true - run: node --version - run: name: webpacker:install command: bundle exec rails webpacker:install - run: name: webpacker:compile command: bundle exec rails webpacker:compile - run: name: Database setup command: bundle exec rails db:migrate - run: name: test command: bundle exec rspec deploy: docker: - image: circleci/ruby:3.0 steps: - checkout - setup_remote_docker: version: 19.03.13 - heroku/install - run: name: heroku login command: heroku container:login - run: name: push docker image command: heroku container:push web -a $HEROKU_APP_NAME - run: name: release docker image command: heroku container:release web -a $HEROKU_APP_NAME - run: name: database setup command: heroku run bundle exec rails db:migrate RAILS_ENV=production -a $HEROKU_APP_NAME workflows: version: 2 build_test_and_deploy: jobs: - build - test: requires: - build - deploy: requires: - test filters: branches: only: main
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 platform: linux/x86_64 web: build: . command: bash -c "rm -f tmp/pids/server.pid && bundle exec rails s -p 3000 -b '0.0.0.0'" volumes: - ./src:/app ports: - "3000:3000" environment: RAILS_ENV: development depends_on: - db
Dockerfile
FROM ruby:3.0 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 entrypoint.sh /entrypoint.sh RUN chmod 744 /entrypoint.sh ENTRYPOINT ["/entrypoint.sh"] EXPOSE 3000 COPY start.sh /start.sh RUN chmod 744 /start.sh CMD ["sh", "/start.sh"]
entrypoint.sh
#!/bin/bash set -e rm -f tmp/pids/server.pid exec "$@"
start.sh
#!/bin/sh if [ "$RAILS_ENV" = "production" ] then bundle exec rails assets:precompile fi echo "PORT $PORT" bundle exec rails s -p 3000 -b 0.0.0.0
開発環境
- MacBook Pro (13-inch, M1, 2020)
- macOS 11.4
- Docker version 20.10.6, build 370c289
- ruby 3.0.1p64 (2021-04-05 revision 0fb782ee38) [arm64-darwin20]
- Rails 6.1.4
足らない情報があればおっしゃっていただけると追加いたします。
ご教示よろしくお願いいたします。
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。