LoginSignup
0
0

More than 1 year has passed since last update.

rails既存アプリにCircleCIでCI/CDを構築するまでの道程で遭遇したエラー

Posted at

やりたいこと

既存アプリに対してCircleCIを導入し、CI/CDを構築する

環境

Ruby 2.6.5
rails 6.0
MySQL 5.6
M1チップ搭載MacOS

目次

1.CI構築
2.CD構築
3.まとめ

1.CI構築

発生したエラー

Failure/Error: <%= javascript_pack_tag 'application'%>

       ActionView::Template::Error:
         Webpacker can't find application in /home/circleci/sample_app/public/packs-test/manifest.json. Possible causes:
         1. You want to set webpacker.yml value of compile to true for your environment
            unless you are using the `webpack -w` or the webpack-dev-server.
         2. webpack has not yet re-run to reflect updates.
         3. You have misconfigured Webpacker's config/webpacker.yml file.
         4. Your webpack configuration is not creating a manifest.
         Your manifest contains:
         {
         }

06dfd6550709d3eadcb8f9e28ea861b5.png

circleciが用意するdockerイメージでrub系でyarnないしnodejs系のコマンドを利用したい場合には、-node がついているイメージを利用する必要がある。

config.yml
docker:
  - image: circleci/ruby:2.6.5-node
config.yml
- run:
    name: yarn Install
    command: yarn install

2. CD構築

発生したエラー
0f88118e8d78d63e5194ad700e49f3ff.png

修正後

config.yml
    name: database setup
              command: heroku run bundle exec rails db:migrate RAILS_ENV=production -a $HEROKU_APP_NAME

ようやくconfig.ymを書上げ、CircleCIもbuild,test,deployと実行され、いざheroku openすると

c5001d6e92fd9c48f7424431d9d9fe1b.png

heroku logs --tailをしてみると

ActionView::Template::Error (Webpacker can't find application in /fridge_app/public/packs/manifest.json. Possible causes:
 1. You want to set webpacker.yml value of compile to true for your environment
    unless you are using the `webpack -w` or the webpack-dev-server.
 2. webpack has not yet re-run to reflect updates.
 3. You have misconfigured Webpacker's config/webpacker.yml file.
 4. Your webpack configuration is not creating a manifest.
    Your manifest contains:
config.yml
 - run:
      name: webpacker compile
      command: bundle exec rails webpacker:compile

webpackerを入れてなくて読み込みができていなかった。

3. まとめ

config.ymlの記述の仕方が難しかったです。インデントやタイポなど単純ミスもありまして、調べながら何度も何度も修正しながら作りました。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0