I am trying to deploy my Rails 6 API app on Railway and keep getting this error:
#18 [stage-0 14/14] RUN bundle exec rake assets:precompile
#18 sha256:20d51ba84b3edc1879a0fe36e13a5cfe583beb59329a77a09bdbd9289c2403d7
#18 4.000 rake aborted!
#18 4.000 Don't know how to build task 'assets:precompile' (See the list of available tasks with `rake --tasks`)
#18 4.000 /usr/local/rvm/gems/ruby-2.7.2/gems/rake-13.0.6/exe/rake:27:in `<top (required)>'
#18 4.000 /usr/local/rvm/gems/ruby-2.7.2/bin/ruby_executable_hooks:22:in `eval'
#18 4.000 /usr/local/rvm/gems/ruby-2.7.2/bin/ruby_executable_hooks:22:in `<main>'
#18 4.000 (See full trace by running task with --trace)
#18 ERROR: executor failed running [/bin/bash -ol pipefail -c bundle exec rake assets:precompile]: exit code: 1
-----
> [stage-0 14/14] RUN bundle exec rake assets:precompile:
-----
executor failed running [/bin/bash -ol pipefail -c bundle exec rake assets:precompile]: exit code: 1
Error: Docker build failed
My application.rb file:
require_relative "boot"
require "rails"
# Pick the frameworks you want:
require "active_model/railtie"
require "active_job/railtie"
require "active_record/railtie"
require "active_storage/engine"
require "action_controller/railtie"
require "action_mailer/railtie"
require "action_mailbox/engine"
require "action_text/engine"
require "action_view/railtie"
require "action_cable/engine"
# require "sprockets/railtie"
require "rails/test_unit/railtie"
# Require the gems listed in Gemfile, including any gems
# you've limited to :test, :development, or :production.
Bundler.require(*Rails.groups)
module AnimeAxisApi
class Application < Rails::Application
# Initialize configuration defaults for originally generated Rails version.
config.load_defaults 6.1
# Configuration for the application, engines, and railties goes here.
#
# These settings can be overridden in specific environments using the files
# in config/environments, which are processed later.
#
# config.time_zone = "Central Time (US & Canada)"
# config.eager_load_paths << Rails.root.join("extras")
# Only loads a smaller set of middleware suitable for API only apps.
# Middleware like session, flash, cookies can be added back manually.
# Skip views, helpers and assets when generating a new resource.
config.api_only = true
config.middleware.use ActionDispatch::Cookies
config.middleware.use ActionDispatch::Session::CookieStore
config.action_dispatch.cookies_same_site_protection = :none
# goes after cookie store
# , key: '_cookie_name'
end
end
Ive added this task in lib/tasks and it still does not stop it the assets:precompile task from running
Rake::Task["assets:precompile"].clear
namespace :assets do
task 'precompile' do
puts "Not pre-compiling assets..."
end
I know that this is because I don't have any assets to compile with an API-only app. I deployed on Heroku previously and did not have this error. I can't find any other posts providing an answer to this, either they mention it and don't provide a solution or it's something to do with Capistrano. I have a plain Rails app. How can I remove this task from being run?