Can't build rails app with buildpacks

Hi,

I am having issues with building my app with packeto builds, so I asked on the buildpack github here: mkdir /workspace/tmp/cache: permission denied · Issue #267 · paketo-buildpacks/rails-assets · GitHub

The error is basically mkdir /workspace/tmp/cache: permission denied

They are asking: do you happen to know how fly.io does the build? Does it use the pack CLI? I'm interested to know the version that's getting used for the build.

Could you please help? Thanks!

app = "lem"
kill_signal = "SIGINT"
kill_timeout = 5

[build]
  builder = "heroku/buildpacks:20"
  buildpacks = ["heroku/nodejs", "heroku/ruby"]

  [build.args]
    SECRET_KEY_BASE="asdf"

[deploy]
  release_command = "bundle exec rails db:migrate recurring:init"

[env]

[experimental]
  allowed_public_ports = []
  auto_rollback = true
  cmd = []
  entrypoint = []
  exec = []

[processes]
  app = "bundle exec puma -C config/puma.rb"
  worker = "bundle exec rails jobs:work"

[[services]]
  http_checks = []
  internal_port = 3000
  processes = ["app"]
  protocol = "tcp"
  script_checks = []
  [services.concurrency]
    hard_limit = 25
    soft_limit = 20
    type = "connections"

  [[services.ports]]
    force_https = true
    handlers = ["http"]
    port = 80

  [[services.ports]]
    handlers = ["tls", "http"]
    port = 443

  [[services.tcp_checks]]
    grace_period = "1s"
    interval = "15s"
    restart_limit = 0
    timeout = "2s"

Seeing similar with heroku buildpacks:

rake aborted!
       Errno::EACCES: Permission denied @ dir_s_mkdir - /workspace/tmp/cache
       /workspace/vendor/bundle/ruby/3.1.0/gems/webpacker-5.4.3/lib/webpacker/compiler.rb:63:in `record_compilation_digest'
       /workspace/vendor/bundle/ruby/3.1.0/gems/webpacker-5.4.3/lib/webpacker/compiler.rb:28:in `block in compile'
       <internal:kernel>:90:in `tap'
       /workspace/vendor/bundle/ruby/3.1.0/gems/webpacker-5.4.3/lib/webpacker/compiler.rb:23:in `compile'
       /workspace/vendor/bundle/ruby/3.1.0/gems/webpacker-5.4.3/lib/webpacker/commands.rb:51:in `compile'
       /workspace/vendor/bundle/ruby/3.1.0/gems/webpacker-5.4.3/lib/webpacker.rb:35:in `compile'
       /workspace/vendor/bundle/ruby/3.1.0/gems/webpacker-5.4.3/lib/tasks/webpacker/compile.rake:23:in `block (4 levels) in <main>'
       /workspace/vendor/bundle/ruby/3.1.0/gems/webpacker-5.4.3/lib/webpacker.rb:28:in `ensure_log_goes_to_stdout'
       /workspace/vendor/bundle/ruby/3.1.0/gems/webpacker-5.4.3/lib/tasks/webpacker/compile.rake:22:in `block (3 levels) in <main>'
       /workspace/vendor/bundle/ruby/3.1.0/gems/webpacker-5.4.3/lib/webpacker.rb:20:in `with_node_env'
       /workspace/vendor/bundle/ruby/3.1.0/gems/webpacker-5.4.3/lib/tasks/webpacker/compile.rake:21:in `block (2 levels) in <main>'
       Tasks: TOP => assets:precompile => webpacker:compile
       (See full trace by running task with --trace)

Any ideas what Fly.io is doing differently with buildpacks? Good people at packeto tested my app and all works fine for them, so it must be something Fly.io specific :frowning:

Anyway, if anyone comes here with similar issue, I solved by migrating to Heroku.

I encountered the similar issue.

  • Rails 7 app
  • SQLite3, with DATABASE_URL configured

In the case, normal DB operation works, but when I added the following to fly.toml then encountered the same error “permisson denied”. As far as I see, nothing wrong with /mnt/ and its subdirectories’ permissions.

[deploy]
  release_command = "bundle exec rails db:seed"

I just wonder if the Rails process are grasping the sqlite3 file during the deploy.

Hope someone would pick this up.

Are you using a Dockerfile or a build pack?

In general, you DO want to put your sqlite3 database on a volume, but do NOT want to use a release_command. What a release command does is launch a machine prior to deploy which does not have access to your volume.