How to precompile assets with Chef?

后端 未结 4 1913
慢半拍i
慢半拍i 2021-02-02 00:27

OpsWorks isn\'t precompiling assets on deploy. I found this recipe in this thread but I think it\'s not complete though, or missing something because I get an error about

4条回答
  •  囚心锁ツ
    2021-02-02 00:51

    Note that if you're passing environment variables to your Rails app using the new OpsWorks feature, you'll need to include these variables in your rake invocation (as they don't get permanently sourced into the deploy user's environment).

    I do the following (based on this article and this recipe) in deploy/before_migrate.rb:

    Chef::Log.info("Precompiling assets for RAILS_ENV=" \
                   "#{new_resource.environment['RAILS_ENV']}...")
    
    execute 'rake assets:precompile' do
      cwd release_path
      command 'bundle exec rake assets:precompile'
      environment new_resource.environment
    end
    

提交回复
热议问题