failed to fetch an image or build from source: error building: failed to solve: executor failed running [/bin/sh -c SECRET_KEY_BASE_DUMMY=1 ./bin/rails assets:precompile]: exit code: 1

Please help me to deploy my small app on fly.io

During command ‘fly deploy’ I get such log with error:

=> [build 2/6] COPY Gemfile Gemfile.lock ./ 0.0s
=> [build 3/6] RUN bundle install && rm -rf ~/.bundle/ “/usr/local/bundle”/ruby//cache “/usr/local/bundle”/ruby//bundler/gems/*/.git && bundle exec bootsnap precompile --gemfile 103.2s
=> [build 4/6] COPY . . 0.0s
=> [build 5/6] RUN bundle exec bootsnap precompile app/ lib/ 0.8s
=> ERROR [build 6/6] RUN SECRET_KEY_BASE_DUMMY=1 ./bin/rails assets:precompile 1.0s

[build 6/6] RUN SECRET_KEY_BASE_DUMMY=1 ./bin/rails assets:precompile:
#0 1.026 bin/rails aborted!
#0 1.026 ExecJS::RuntimeUnavailable: Could not find a JavaScript runtime. See GitHub - rails/execjs: Run JavaScript code from Ruby for a list of available runtimes. (ExecJS::RuntimeUnavailable)
#0 1.026 /usr/local/bundle/ruby/3.2.0/gems/execjs-2.9.1/lib/execjs/runtimes.rb:68:in autodetect' #0 1.026 /usr/local/bundle/ruby/3.2.0/gems/execjs-2.9.1/lib/execjs.rb:5:in module:ExecJS
#0 1.026 /usr/local/bundle/ruby/3.2.0/gems/execjs-2.9.1/lib/execjs.rb:4:in <main>' #0 1.026 <internal:/usr/local/lib/ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:37:in require’
#0 1.026 internal:/usr/local/lib/ruby/3.2.0/rubygems/core_ext/kernel_require.rb:37:in require' #0 1.026 /usr/local/bundle/ruby/3.2.0/gems/bootsnap-1.17.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in require’
#0 1.026 /usr/local/bundle/ruby/3.2.0/gems/zeitwerk-2.6.12/lib/zeitwerk/kernel.rb:38:in require' #0 1.026 /usr/local/bundle/ruby/3.2.0/gems/autoprefixer-rails-10.4.16.0/lib/autoprefixer-rails/processor.rb:4:in
#0 1.026 /usr/local/bundle/ruby/3.2.0/gems/autoprefixer-rails-10.4.16.0/lib/autoprefixer-rails.rb:39:in require_relative' #0 1.026 /usr/local/bundle/ruby/3.2.0/gems/autoprefixer-rails-10.4.16.0/lib/autoprefixer-rails.rb:39:in
#0 1.026 internal:/usr/local/lib/ruby/3.2.0/rubygems/core_ext/kernel_require.rb:37:in require' #0 1.026 <internal:/usr/local/lib/ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:37:in require’
#0 1.026 /usr/local/bundle/ruby/3.2.0/gems/bootsnap-1.17.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in require' #0 1.026 /usr/local/bundle/ruby/3.2.0/gems/zeitwerk-2.6.12/lib/zeitwerk/kernel.rb:38:in require’
#0 1.026 /usr/local/bundle/ruby/3.2.0/gems/bootstrap-5.3.2/lib/bootstrap/engine.rb:3:in <main>' #0 1.026 <internal:/usr/local/lib/ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:37:in require’
#0 1.026 internal:/usr/local/lib/ruby/3.2.0/rubygems/core_ext/kernel_require.rb:37:in require' #0 1.026 /usr/local/bundle/ruby/3.2.0/gems/bootsnap-1.17.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in require’
#0 1.026 /usr/local/bundle/ruby/3.2.0/gems/zeitwerk-2.6.12/lib/zeitwerk/kernel.rb:38:in require' #0 1.026 /usr/local/bundle/ruby/3.2.0/gems/bootstrap-5.3.2/lib/bootstrap.rb:61:in register_rails_engine’
#0 1.026 /usr/local/bundle/ruby/3.2.0/gems/bootstrap-5.3.2/lib/bootstrap.rb:11:in load!' #0 1.026 /usr/local/bundle/ruby/3.2.0/gems/bootstrap-5.3.2/lib/bootstrap.rb:75:in
#0 1.026 internal:/usr/local/lib/ruby/3.2.0/rubygems/core_ext/kernel_require.rb:37:in require' #0 1.026 <internal:/usr/local/lib/ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:37:in require’
#0 1.026 /usr/local/bundle/ruby/3.2.0/gems/bootsnap-1.17.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in require' #0 1.026 /usr/local/bundle/ruby/3.2.0/gems/zeitwerk-2.6.12/lib/zeitwerk/kernel.rb:38:in require’
#0 1.026 /rails/config/application.rb:21:in <main>' #0 1.026 /rails/Rakefile:6:in require_relative’
#0 1.026 /rails/Rakefile:6:in <main>' #0 1.026 /usr/local/bundle/ruby/3.2.0/gems/railties-7.1.2/lib/rails/commands/rake/rake_command.rb:43:in block in with_rake’
#0 1.026 /usr/local/bundle/ruby/3.2.0/gems/railties-7.1.2/lib/rails/commands/rake/rake_command.rb:41:in with_rake' #0 1.026 /usr/local/bundle/ruby/3.2.0/gems/railties-7.1.2/lib/rails/commands/rake/rake_command.rb:20:in perform’
#0 1.026 /usr/local/bundle/ruby/3.2.0/gems/railties-7.1.2/lib/rails/command.rb:156:in invoke_rake' #0 1.026 /usr/local/bundle/ruby/3.2.0/gems/railties-7.1.2/lib/rails/command.rb:73:in block in invoke’
#0 1.026 /usr/local/bundle/ruby/3.2.0/gems/railties-7.1.2/lib/rails/command.rb:149:in with_argv' #0 1.026 /usr/local/bundle/ruby/3.2.0/gems/railties-7.1.2/lib/rails/command.rb:69:in invoke’
#0 1.026 /usr/local/bundle/ruby/3.2.0/gems/railties-7.1.2/lib/rails/commands.rb:18:in <main>' #0 1.026 <internal:/usr/local/lib/ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:37:in require’
#0 1.026 internal:/usr/local/lib/ruby/3.2.0/rubygems/core_ext/kernel_require.rb:37:in require' #0 1.026 /usr/local/bundle/ruby/3.2.0/gems/bootsnap-1.17.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in require’
#0 1.026 ./bin/rails:6:in `’
#0 1.026 (See full trace by running task with --trace)

Are you using the Dockerfile that rails provided or did you let us generate one for you?

Try:

bin/rails generate dockerfile

yes, it helped me, but I faced with new error:

Provisioning ips for sewcon
  Dedicated ipv6: 2a09:8280:1::2d:cef2
  Shared ipv4: 66.241.125.241
  Add a dedicated ipv4 with: fly ips allocate-v4

Running sewcon release_command: ./bin/rails db:prepare

-------
 ✖ release_command failed
-------
Error release_command failed running on machine 148e135a292289 with exit code 1.
Check its logs: here's the last 100 lines below, or run 'fly logs -i 148e135a292289':
  Pulling container image registry.fly.io/sewcon:deployment-01HJRDQSN2AH7VSFQRXZK37MNP
  Successfully prepared image registry.fly.io/sewcon:deployment-01HJRDQSN2AH7VSFQRXZK37MNP (12.656845994s)
  [    0.037681] PCI: Fatal: No config space access function found
   INFO Starting init (commit: 15238e9)...
   INFO Preparing to run: `/rails/bin/docker-entrypoint ./bin/rails db:prepare` as 1000
   INFO [fly api proxy] listening at /.fly/api
  2023/12/28 14:41:06 listening on [fdaa:4:8b67:a7b:c8:6e0:91c3:2]:22 (DNS: [fdaa::3]:53)
  /rails/bin/rails:5:in `require_relative': cannot load such file -- /rails/config/boot (LoadError)
  	from /rails/bin/rails:5:in `<main>'
   INFO Main child exited normally with code: 1
   INFO Starting clean up.
   WARN hallpass exited, pid: 315, status: signal: 15 (SIGTERM)
  2023/12/28 14:41:07 listening on [fdaa:4:8b67:a7b:c8:6e0:91c3:2]:22 (DNS: [fdaa::3]:53)
  [    2.342357] reboot: Restarting system
  machine restart policy set to 'no', not restarting
-------
Error: release command failed - aborting deployment. error release_command machine 148e135a292289 exited with non-zero status of 1

What does this file contain? bin/rails generate dockerfile should have replaced it with:

#!/bin/bash -e

# Add any container initialization steps here

exec "${@}"

yes, this file contains the same
image

Maybe I fill database.yml incorrectly? Could you plesae show me the right example of this file for prodaction with postgres?

I’ve saved all data that I got during the comand ‘fly launch’. But I’m affraid that I filled it (database.yml) wrongly.

Should I show my dockerfile and fly.toml here?

I apologize that I’m so persistent, but could please help me and move me into right direction? Thanks in advance :wink:

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.