fly deploy, env var issue

Hi folks,

As many of us are, I’m attempting to migrate from Heroku. Unfortunately, I have not been super successful yet in getting a single Rails app running correctly. Turboku doesn’t seem to offer a clean break as such, so I’m opting to fly launch from scratch and mover over databases/envs manually.

My Rails apps are generally built using thoughtbot/suspenders and therefore there are a few env vars in app/config/environments/production.rb etc.

Upon fly deploy --remote-only, the build fails as it seemingly doesn’t have access to the enviromental variables:

 => ERROR [stage-4 5/5] RUN bundle exec rails assets:precompile                                                                                                                                                                                 4.0s
------
 > [stage-4 5/5] RUN bundle exec rails assets:precompile:
#23 3.882 rails aborted!
#23 3.882 KeyError: key not found: "APPLICATION_HOST"
#23 3.882 /app/config/environments/production.rb:8:in `fetch'
#23 3.882 /app/config/environments/production.rb:8:in `block in <main>'

Any help would be really appreciated! Fly is looking great so far as a contender to Heroku.

Cheers,
Rikki

1 Like

If running assets:precompile doesn’t work for you at build time, you might have more luck moving it to be run as a part of the start command. Try taking a look at Mount and Prep for Deployment, skipping the [mount] step and making the two changes to fly.toml and then creating a custom rake task.

1 Like