Rails app crashes when a volume is mounted
kennyki
PROOP

3 months ago

Hi there,

I have a Rails app on SQLite, where the database.yml defines production databases in the "storage" dir, i.e.,

database: storage/production.sqlite3

There is no issue with building, deploying, and starting the service, only that it's writing to the ephemeral filesystem, which is expected. Tried SSH into the service and the databases are indeed created in "/rails/storage".

Taking reference from the Fizzy + SQLite template (which I tried and have successfully deployed), the volume to attached to the service should have mount path "/rails/storage"

So I created a volume with the same mount path. However, when it's deploying, the rails container will crash with the following errors in the Deploy logs

Mounting volume on: /var/lib/containers/railwayapp/bind-mounts/d16d320b-ecf2-422c-8145-8d831dbf6c50/vol_pnxefi4fpe6s5v9h
Starting Container
Tasks: TOP => db:prepare
(See full trace by running task with --trace)
bin/rails aborted!
ActiveRecord::StatementInvalid: SQLite3::CantOpenException: unable to open database file (ActiveRecord::StatementInvalid)

What's going on?

Solved

1 Replies

kennyki
PROOP

3 months ago

Oh wow, I noticed a special ENV var in the Fizzy template: RAILWAY_RUN_UID=0 and for the sake of trying I added it, it worked!

Further searches reveals this statement:

  • Docker images that run as a non-root UID by default will have permissions issues when performing operations within an attached volume. If you are affected by this, you can set RAILWAY_RUN_UID=0 environment variable in your service.

Not exactly suggested for the error I'm seeing, but it solves that. I hope this can help someone else with the same error.


Status changed to Solved sam-a 2 months ago


Welcome!

Sign in to your Railway account to join the conversation.

Loading...