Error: release command failed - aborting deployment. error release_command machine 5683623ae3708e exited with non-zero status of 1

Hi guys!

I faced with one problem during deploy (fly deploy) of my small app. Maybe somebody knows how to fix it.

The log of deployment is next:

--> Building image done
==> Pushing image to fly
The push refers to repository [registry.fly.io/sewcon]
79a2d0cdc077: Pushed 
a2b42218d512: Pushed 
f9325ba5b5f3: Pushed 
8ffe22cf8b14: Layer already exists 
b61a41ba0c13: Layer already exists 
cf09198a83b8: Layer already exists 
242dc5346dec: Layer already exists 
f87696163903: Layer already exists 
214d39b6280a: Layer already exists 
138afe438ab3: Layer already exists 
959e4e92bf39: Layer already exists 
67c6b910abbc: Layer already exists 
7292cf786aa8: Layer already exists 
deployment-01HJT6ZBDZ65QB07Q0GW636S9Z: digest: sha256:5476e55c16e19ec717aae398883cce4b8df2bdc9b4d7da451ff7447f98ee9c5a size: 3055
--> Pushing image done
image: registry.fly.io/sewcon:deployment-01HJT6ZBDZ65QB07Q0GW636S9Z
image size: 609 MB

Watch your deployment at https://fly.io/apps/sewcon/monitoring

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

-------
 ✖ release_command failed
-------
Error release_command failed running on machine 5683623ae3708e with exit code 1.
Check its logs: here's the last 100 lines below, or run 'fly logs -i 5683623ae3708e':
  Pulling container image registry.fly.io/sewcon:deployment-01HJT6ZBDZ65QB07Q0GW636S9Z
  Successfully prepared image registry.fly.io/sewcon:deployment-01HJT6ZBDZ65QB07Q0GW636S9Z (8.991958793s)
  Configuring firecracker
  [    0.038995] 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/29 07:20:29 listening on [fdaa:4:8b67:a7b:c8:4fcc:334: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/29 07:20:30 listening on [fdaa:4:8b67:a7b:c8:4fcc:334:2]:22 (DNS: [fdaa::3]:53)
  [    2.354197] reboot: Restarting system
  machine restart policy set to 'no', not restarting
-------
Error: release command failed - aborting deployment. error release_command machine 5683623ae3708e exited with non-zero status of 1
artemzybin@Air-Artem-TOKO sewcon %

My fly.toml

# fly.toml app configuration file generated for sewcon on 2023-12-28T16:14:34+02:00
#
# See https://fly.io/docs/reference/configuration/ for information about how to use this file.
#

app = "sewcon"
primary_region = "waw"
console_command = "/rails/bin/rails console"

[build]

[deploy]
  release_command = "./bin/rails db:prepare"

[http_service]
  internal_port = 3000
  force_https = true
  auto_stop_machines = true
  auto_start_machines = true
  min_machines_running = 0
  processes = ["app"]

[[vm]]
  cpu_kind = "shared"
  cpus = 1
  memory_mb = 256

[[statics]]
  guest_path = "/rails/public"
  url_prefix = "/"

My Dockerfile:

# syntax = docker/dockerfile:1

# Make sure RUBY_VERSION matches the Ruby version in .ruby-version and Gemfile
ARG RUBY_VERSION=3.2.2
FROM ruby:$RUBY_VERSION-slim as base

LABEL fly_launch_runtime="rails"

# Rails app lives here
WORKDIR /rails

# Set production environment
ENV BUNDLE_DEPLOYMENT="1" \
    BUNDLE_PATH="/usr/local/bundle" \
    BUNDLE_WITHOUT="development:test" \
    RAILS_ENV="production"

# Update gems and bundler
RUN gem update --system --no-document && \
    gem install -N bundler

# Install packages needed to install nodejs
RUN apt-get update -qq && \
    apt-get install --no-install-recommends -y curl && \
    rm -rf /var/lib/apt/lists /var/cache/apt/archives

# Install Node.js
ARG NODE_VERSION=18.18.1
ENV PATH=/usr/local/node/bin:$PATH
RUN curl -sL https://github.com/nodenv/node-build/archive/master.tar.gz | tar xz -C /tmp/ && \
    /tmp/node-build-master/bin/node-build "${NODE_VERSION}" /usr/local/node && \
    rm -rf /tmp/node-build-master


# Throw-away build stage to reduce size of final image
FROM base as build

# Install packages needed to build gems
RUN apt-get update -qq && \
    apt-get install --no-install-recommends -y build-essential libpq-dev

# Build options
ENV PATH="/usr/local/node/bin:$PATH"

# Install application gems
COPY --link Gemfile Gemfile.lock ./
RUN bundle install && \
    bundle exec bootsnap precompile --gemfile && \
    rm -rf ~/.bundle/ "${BUNDLE_PATH}"/ruby/*/cache "${BUNDLE_PATH}"/ruby/*/bundler/gems/*/.git

# Copy application code
COPY --link . .

# Precompile bootsnap code for faster boot times
RUN bundle exec bootsnap precompile app/ lib/

# Precompiling assets for production without requiring secret RAILS_MASTER_KEY
RUN SECRET_KEY_BASE_DUMMY=1 ./bin/rails assets:precompile


# Final stage for app image
FROM base

# Install packages needed for deployment
RUN apt-get update -qq && \
    apt-get install --no-install-recommends -y curl postgresql-client && \
    rm -rf /var/lib/apt/lists /var/cache/apt/archives

# Copy built artifacts: gems, application
COPY --from=build /usr/local/bundle /usr/local/bundle
COPY --from=build /rails /rails

# Run and own only the runtime files as a non-root user for security
RUN groupadd --system --gid 1000 rails && \
    useradd rails --uid 1000 --gid 1000 --create-home --shell /bin/bash && \
    chown -R 1000:1000 db log storage tmp
USER 1000:1000

# Entrypoint sets up the container.
ENTRYPOINT ["/rails/bin/docker-entrypoint"]

# Start the server by default, this can be overwritten at runtime
EXPOSE 3000
CMD ["./bin/rails", "server"]

I’m grateful in advance to everyone who will not pass by and try to help me :wink:

I can see the relevant log lines from your deploy are these:

  /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

Can you verify your config/boot.rb exists and if its not in your gitignore or dockerignore?

No, my gitignore and dockerignore files don’t include this file. I’ve also checked availibility of this file, it is in project (please see screenshot).

image

My gitignore:

# See https://help.github.com/articles/ignoring-files for more about ignoring files.
#
# If you find yourself ignoring temporary files generated by your text editor
# or operating system, you probably want to add a global ignore instead:
#   git config --global core.excludesfile '~/.gitignore_global'

# Ignore bundler config.
/.bundle

# Ignore all environment files (except templates).
/.env*
!/.env*.erb

.idea/*
/.idea/*

# Ignore all logfiles and tempfiles.
/log/*
/tmp/*
!/log/.keep
!/tmp/.keep

# Ignore pidfiles, but keep the directory.
/tmp/pids/*
!/tmp/pids/
!/tmp/pids/.keep

# Ignore storage (uploaded files in development and any SQLite databases).
/storage/*
!/storage/.keep
/tmp/storage/*
!/tmp/storage/
!/tmp/storage/.keep

/public/assets

# Ignore master key for decrypting credentials and more.
/config/master.key
/readme_comands.txt

My dockerignore:

# See https://docs.docker.com/engine/reference/builder/#dockerignore-file for more about ignoring files.

# Ignore git directory.
/.git/

# Ignore bundler config.
/.bundle

# Ignore all environment files (except templates).
/.env*
!/.env*.erb

# Ignore all default key files.
/config/master.key
/config/credentials/*.key

# Ignore all logfiles and tempfiles.
/log/*
/tmp/*
!/log/.keep
!/tmp/.keep

# Ignore pidfiles, but keep the directory.
/tmp/pids/*
!/tmp/pids/.keep

# Ignore storage (uploaded files in development and any SQLite databases).
/storage/*
!/storage/.keep
/tmp/storage/*
!/tmp/storage/.keep

# Ignore assets.
/node_modules/
/app/assets/builds/*
!/app/assets/builds/.keep
/public/assets

My boot.rb file includes the following lines:

# frozen_string_literal: true

ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)

require 'bundler/setup' # Set up gems listed in the Gemfile.
require 'bootsnap/setup' # Speed up boot time by caching expensive operations.

What makes this hard is that we can’t see your application, and in all likelihood you’ve never seen a successful deploy. So let’s address the latter. Try running:

rails new demo-24712
cd demo-24712
echo 'Rails.application.routes.draw { root "rails/welcome#index" }' > config/routes.rb
fly launch
bin/rails generate dockerfile --force
fly deploy
fly apps open

(feel free to pick your own random demo name)

The above will create an app using pg and display a welcome screen. Once that is complete, try running:

fly console -C bash
/rails/bin/docker-entrypoint ./bin/rails db:prepare

This will complete successfully on the demo. Now try the above two commands on your app.

Now the question to be resolved is what is the difference between this demo and your application?

Thanks, it works. But I’ll be happy to start my app )))
I think that one big difference between demo-24712 app and my one is the postgres database.
So, I would like to ask you, should I change my database.yml for production after the comand “fly launch”. I mean that I got the next info after this comand:

Postgres cluster myApp-db created
  Username:    postgres
  Password:    somePassword
  Hostname:    sewcon-db.internal
  Flycast:     fdaa:4:8b67:0:1::8
  Proxy port:  5432
  Postgres port:  5433
  Connection string: postgres://postgres:somePassword@myApp-db.flycast:5432

Save your credentials in a secure place -- you won't be able to see them again!

So, if I should do some changes, could you please write me the sample of database.yml with the values of database that was created after the “fly launch” comannd?

According to the log I have “Error release_command failed”, but release_comand = ./bin/rails db:prepare, so I think that my problem in database settings.

Tell me please what sould I do with with the data of databese that I got after the command “fly launch”.

Thank you in advance

demo 24712 does deploy with a postgres database, and even successfully runs db:prepare against it. The database isn’t specified in config/database.yml. Instead it is defined by the DATABASE_URL environment variable. You can query the value of this using:

fly console -C "printenv DATABASE_URL"

See Configuring Rails Applications — Ruby on Rails Guides for more information.

By contrast, your application appears to fail well before it opens the database:

Without seeing your application, I can’t speculate as to why config/boot fails to load.

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