Error when I try to deploy a rails app: ERROR [build 6/6] RUN SECRET_KEY_BASE_DUMMY=1 ./bin/rails assets:precompile

Hello to everyone, I have troubles when I try to execute the command fly deploy with a rails 7 app, the next lines are the log after execute the command:

==> Verifying app config
Validating /Users/impulsalabs/Documents/proyectos/apptestingone/fly.toml
✓ Configuration is valid
--> Verified app config
==> Building image
Remote builder fly-builder-aged-rain-6550 ready
Remote builder fly-builder-aged-rain-6550 ready
==> Building image with Docker
--> docker host: 24.0.7 linux x86_64
[+] Building 5.6s (16/19)
 => [internal] load .dockerignore                                                                                                                                       0.1s
 => => transferring context: 782B                                                                                                                                       0.1s
 => [internal] load build definition from Dockerfile                                                                                                                    0.1s
 => => transferring dockerfile: 2.14kB                                                                                                                                  0.1s
 => resolve image config for docker.io/docker/dockerfile:1                                                                                                              0.3s
 => CACHED docker-image://docker.io/docker/dockerfile:1@sha256:fe40cf4e92cd0c467be2cfc30657a680ae2398318afd50b0c80585784c604f28                                         0.0s
 => [internal] load metadata for docker.io/library/ruby:3.3.0-slim                                                                                                      0.1s
 => [internal] load build context                                                                                                                                       0.5s
 => => transferring context: 51.96kB                                                                                                                                    0.5s
 => [base 1/3] FROM docker.io/library/ruby:3.3.0-slim@sha256:d19b39b55078ce9d52c6c6f5ab2aee41b17bee4e18c0bfc734eceaa6f7972c1c                                           0.0s
 => CACHED [base 2/3] WORKDIR /rails                                                                                                                                    0.0s
 => CACHED [base 3/3] RUN gem update --system --no-document &&     gem install -N bundler                                                                               0.0s
 => CACHED [stage-2 1/4] RUN apt-get update -qq &&     apt-get install --no-install-recommends -y curl imagemagick libsqlite3-0 libvips postgresql-client &&     rm -r  0.0s
 => CACHED [build 1/6] RUN apt-get update -qq &&     apt-get install --no-install-recommends -y build-essential git libpq-dev libvips pkg-config                        0.0s
 => CACHED [build 2/6] COPY --link Gemfile Gemfile.lock ./                                                                                                              0.0s
 => CACHED [build 3/6] RUN bundle install &&     bundle exec bootsnap precompile --gemfile &&     rm -rf ~/.bundle/ "/usr/local/bundle"/ruby/*/cache "/usr/local/bundl  0.0s
 => CACHED [build 4/6] COPY --link . .                                                                                                                                  0.0s
 => CACHED [build 5/6] RUN bundle exec bootsnap precompile app/ lib/                                                                                                    0.0s
 => ERROR [build 6/6] RUN SECRET_KEY_BASE_DUMMY=1 ./bin/rails assets:precompile                                                                                         4.4s
------
 > [build 6/6] RUN SECRET_KEY_BASE_DUMMY=1 ./bin/rails assets:precompile:
2.924
2.924 ⚡ Motor::Admin is starting under /admin
2.924
3.762
3.763 Rebuilding...
4.285
4.285 Done in 600ms.
4.323 yarn install failed to execute.
4.323 Ensure yarn is installed and `yarn --version` runs without errors.
------
==> Building image
✓ compatible remote builder found
INFO Override builder host with: https://fly-builder-aged-rain-6550.fly.dev (was tcp://[fdaa:a:6f1:a7b:6b:d740:4bc9:2]:2375)

Remote builder fly-builder-aged-rain-6550 ready
INFO Override builder host with: https://fly-builder-aged-rain-6550.fly.dev (was tcp://[fdaa:a:6f1:a7b:6b:d740:4bc9:2]:2375)

Remote builder fly-builder-aged-rain-6550 ready
==> Building image with Docker
--> docker host: 24.0.7 linux x86_64
[+] Building 5.4s (16/19)
 => [internal] load build definition from Dockerfile                                                                                                                    0.1s
 => => transferring dockerfile: 2.14kB                                                                                                                                  0.1s
 => [internal] load .dockerignore                                                                                                                                       0.1s
 => => transferring context: 782B                                                                                                                                       0.1s
 => resolve image config for docker.io/docker/dockerfile:1                                                                                                              0.3s
 => CACHED docker-image://docker.io/docker/dockerfile:1@sha256:fe40cf4e92cd0c467be2cfc30657a680ae2398318afd50b0c80585784c604f28                                         0.0s
 => [internal] load metadata for docker.io/library/ruby:3.3.0-slim                                                                                                      0.1s
 => [base 1/3] FROM docker.io/library/ruby:3.3.0-slim@sha256:d19b39b55078ce9d52c6c6f5ab2aee41b17bee4e18c0bfc734eceaa6f7972c1c                                           0.0s
 => [internal] load build context                                                                                                                                       0.3s
 => => transferring context: 51.96kB                                                                                                                                    0.3s
 => CACHED [base 2/3] WORKDIR /rails                                                                                                                                    0.0s
 => CACHED [base 3/3] RUN gem update --system --no-document &&     gem install -N bundler                                                                               0.0s
 => CACHED [stage-2 1/4] RUN apt-get update -qq &&     apt-get install --no-install-recommends -y curl imagemagick libsqlite3-0 libvips postgresql-client &&     rm -r  0.0s
 => CACHED [build 1/6] RUN apt-get update -qq &&     apt-get install --no-install-recommends -y build-essential git libpq-dev libvips pkg-config                        0.0s
 => CACHED [build 2/6] COPY --link Gemfile Gemfile.lock ./                                                                                                              0.0s
 => CACHED [build 3/6] RUN bundle install &&     bundle exec bootsnap precompile --gemfile &&     rm -rf ~/.bundle/ "/usr/local/bundle"/ruby/*/cache "/usr/local/bundl  0.0s
 => CACHED [build 4/6] COPY --link . .                                                                                                                                  0.0s
 => CACHED [build 5/6] RUN bundle exec bootsnap precompile app/ lib/                                                                                                    0.0s
 => ERROR [build 6/6] RUN SECRET_KEY_BASE_DUMMY=1 ./bin/rails assets:precompile                                                                                         4.5s
------
 > [build 6/6] RUN SECRET_KEY_BASE_DUMMY=1 ./bin/rails assets:precompile:
2.975
2.975 ⚡ Motor::Admin is starting under /admin
2.975
3.817
3.817 Rebuilding...
4.363
4.364 Done in 618ms.
4.398 yarn install failed to execute.
4.398 Ensure yarn is installed and `yarn --version` runs without errors.
------
Error: failed to fetch an image or build from source: error building: failed to solve: process "/bin/sh -c SECRET_KEY_BASE_DUMMY=1 ./bin/rails assets:precompile" did not complete successfully: exit code: 1

This is my my fly.toml file:

# fly.toml app configuration file generated for travel-ecommerce on 2024-09-01T22:29:21-06:00
#
# See https://fly.io/docs/reference/configuration/ for information about how to use this file.
#

app = 'apptestingone'
primary_region = 'dfw'
console_command = '/rails/bin/rails console'

[build]

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

[env]

[processes]
  app = "./bin/rails server"
  sidekiq = "bundle exec sidekiq"

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

[checks]
  [checks.status]
    port = 3000
    type = 'http'
    interval = '10s'
    timeout = '2s'
    grace_period = '5s'
    method = 'GET'
    path = "⚠️  Motor::Admin is not mounted.\nAdd the following line to your config/routes.rb:\n\n    mount Motor::Admin => '/admin'\n\n/up"
    protocol = 'http'
    tls_skip_verify = false

    [checks.status.headers]
      X-Forwarded-Proto = 'https'

[[vm]]
  memory = '1gb'
  cpu_kind = 'shared'
  cpus = 1

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

Currently I don’t have so many secret keys, for something that read in another thread, I set the secret with the rails master key content with the next line:

fly secrets set RAILS_MASTER_KEY=$(cat config/master.key)

When I execute in my terminal the line:

SECRET_KEY_BASE_DUMMY=1 ./bin/rails assets:precompile

is working, even when I check “yarn --version” as the log suggest, is working, ¿what do you think I’m missing?.

Thanks for your time in read the thread

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