This is probably not a Fly issue; but on the odd chance that this is related to static files/nginx or some like setting like that, I’m posting here. Also want to note that when I build and run the same exact Dockerfile locally, I don’t get this issue.
I suddenly started having this problem in my production box where most of the css assets are compiled, except for the 3 assets I tell dartsass to build, application.css
and two others here:
config/initializers/dartsass.rb
# config/initializers/dartsass.rb
Rails.application.config.dartsass.builds = {
"application.scss" => "application.css",
"mailer.scss" => "mailer.css",
"active_admin.scss" => "active_admin.css"
}
Immediately after deploying, public/assets
only has the scss files and the .manifest.json also does not reference the .css files (because they don’t exist in public/assets
:
root@3d8d9296ce7948:/rails# cat public/assets/.manifest.json
{"active_admin.js":"active_admin-9383b93bd6d1d9fa0a36586f11fbb66bf00abbe8.js","application.scss":"application-7596f0d55dbc14bbba8357ba2519b6a92c1ba3e5.scss","active_admin.scss":"active_admin-b3484b0fe9d5b655c7bfabf44d4844d3f578e38c.scss","base/sizes.scss":"base/
root@3d8d9296ce7948:/rails# ls public/assets/ | grep application
application-7596f0d55dbc14bbba8357ba2519b6a92c1ba3e5.scss
application-8c437f3aabfc2ca3fdda87f69e6041a7e3c5f5e3.js
After I run assets:precompile again on the box, the assets are generated:
root@3d8d9296ce7948:/rails# bin/rails assets:precompile
I, [2024-02-24T22:12:30.174296 #329] INFO -- : Writing application-23b791d200e0a4700af4b77c5bd2aea477b5575c.css
I, [2024-02-24T22:12:30.205423 #329] INFO -- : Writing active_admin-9d8f9c30e6ef1f119225b74cf213f50721c80914.css
I, [2024-02-24T22:12:30.205963 #329] INFO -- : Writing mailer-0e34617c354ffe5379b296cf599c202195eab754.css
root@3d8d9296ce7948:/rails# ls public/assets/ | grep application
application-23b791d200e0a4700af4b77c5bd2aea477b5575c.css
root@3d8d9296ce7948:/rails# cat public/assets/.manifest.json
{"application.css":"application-23b791d200e0a4700af4b77c5bd2aea477b5575c.css","active_admin.css":"active_admin-9d8f9c30e6ef1f119225b74cf213f50721c80914.css","mailer.css":"mailer-0e34617c354ffe5379b296cf599c202195eab754.css"
The thing is, I am already doing assets:precompile in my Dockerfile and copying the output to the final image:
FROM ... as build
# Precompiling assets for production without requiring secret RAILS_MASTER_KEY
RUN SECRET_KEY_BASE=DUMMY ./bin/rails assets:precompile
...
COPY --from=build /rails /rails
Not sure why this started happening, as I haven’t updated much of anything. Appreciate any ideas.
gem versions:
rails (7.0.7.2)
propshaft (0.8.0)
dartsass-rails (0.5.0)