I'm trying to evaluate Fly.io and deploy an existing Rails 7 app. Following their guide for existing rails apps, fly launch
works fine, however fly deploy
fails on the assets:precompile
step.
Console Ouput:
=> [build 5/6] RUN bundle exec bootsnap precompile app/ lib/ 1.1s
=> ERROR [build 6/6] RUN SECRET_KEY_BASE_DUMMY=1 ./bin/rails assets:precompile 2.1s
------
> [build 6/6] RUN SECRET_KEY_BASE_DUMMY=1 ./bin/rails assets:precompile:
#16 2.043 Missing encryption key to decrypt file with. Ask your team for your master key and write it to /rails/config/master.key or put it in the ENV['RAILS_MASTER_KEY'].
------
Error failed to fetch an image or build from source: error building: executor failed running [/bin/sh -c SECRET_KEY_BASE_DUMMY=1 ./bin/rails assets:precompile]: exit code: 1
Obviously, this is a common enough problem that it’s mentioned in Fly's Getting Started Guide
I have my Rails master key in the correct config file (config/master.key), and the error output even links to the file.
Fly launch successfully created the RAILS_MASTER_KEY
env variable and I’ve confirmed that the key is correct.
My secret_key_base
is in the rails credentials file.
I've tried setting the Dockerfile to both of these:
RUN SECRET_KEY_BASE=DUMMY ./bin/rails assets:precompile
RUN SECRET_KEY_BASE_DUMMY=1 ./bin/rails assets:precompile
Both result in the same error
There's also this issue on github, but the solution to that seems to be the dummy secret key base.
Any suggestions for what to try in order to resolve this?