Rails 请教在 docker 制作镜像预编译时 怎样不链接数据库

ghn645568344 · September 15, 2022 · Last by piecehealth replied at September 16, 2022 · 260 hits

ruby:2.5.0 rails:5.2.0 在 docker 制作镜像时候,执行

bundle exec  rails assets:precompile

提示要链接数据库,请教怎么跳过这步链接数据库的请求? 网上的说要加入

config.assets.initialize_on_precompile = false

但是不太好用,请教有没有别的办法?该怎么做

RUN bundle exec rails assets:precompile RAILS_ENV=production SECRET_KEY_BASE=fake
2 Floor has deleted
Reply to qichunren

还是同样的报错😷

因为你在 config 或者 initializer 中有数据库操作。assets:precompile 本身不需要连接数据库的,看一下错误堆栈,找到连数据库的代码,想办法避免启动的时候执行。

You need to Sign in before reply, if you don't have an account, please Sign up first.