13
8

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

assets:precompileするさいにactiverecord-nulldb-adapterを使ってdb接続を避ける

Posted at

rake assets:precompileをDockerfileの中に書いて```docker build``するとdbにつながらないといったエラーが出るので、build時はdbのadapterをnulldbに変更して本番DBへ接続しないようにした。

設定

  • Gemfile
gem 'activerecord-nulldb-adapter'
  • config/database.yml
defaults: &defaults
  adapter: <%= ENV['DB_ADAPTER'] ||= "mysql2" %>
  encoding: utf8
  • Dockerfile
FROM hoge_rails_apps_base:latest

RUN DB_ADAPTER=nulldb bundle exec rake -t assets:precompile RAILS_ENV=production

CMD ["/start.sh"]

参考になりました

13
8
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
13
8

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?