tamatebako / tebako

Tebako: an executable packager (for Ruby programs)
https://www.tebako.org
41 stars 6 forks source link

Create a bypass for hardcoded rails tmp folder #185

Open maxirmx opened 1 month ago

maxirmx commented 1 month ago

Rails has hardcoded path to tmp folder as described in https://github.com/rails/rails/issues/39583 If tebako is used this path is within memfs, is readonly and cannot be used for temporarily files

We either patch it tebako-runtime or implement a feature similar to docker volume.

ronaldtse commented 1 month ago

The docker volume functionality is described here:

maxirmx commented 1 month ago

I am afraid Rails support reuires a 'real' filesystem. 'Real' here means a file system which is accessible by other processes. For example, Rails tmp folder contains pid and restart files that shall be used to send commands/signals to tebako package or log files that would be nice to keep when tebako package terminates.

If we 'embed' OverlayFS in a way we do it with DwarFS it won't be accesiible from other processes.

So even with docker-style volumes they have to link to a filesystem that is mounted by the operating system. It can be OverlayFS, of course.

ronaldtse commented 1 month ago

In this case, it can only be a directory created inside the system $TMPDIR? i.e. it is not a self-contained working directory.

maxirmx commented 1 month ago

As far as I understand Rails have 'tmp' and 'cache' Cache may be self-contained and OverlayFS will suit perfectly Tmp has to be 'real'. It is configurable but there are three Rails methods that ignore configuration and use hardcoded File.join(Rails.root, "tmp") instead of config.paths["tmp"]

This issue did not exist in the ruby-packer times.

I see three possible approaches to it:

  1. The fast method is to patch rails 'on the fly' so that it honours its own configuration.
  2. The other fast method is to (optionally) support mapping of /__tebako_memfs__/tmp to system folder. In this case the user can start tebako package app with additional parameter like app --with-tebako-tmp-folder=$TMPDIR/rails
  3. The solid method is to implement generic mapping of memfs folder to system folder like docker --volume
    app --tebako-volume=tmp:$TMPDIR/rails

Methods 1,2 will take a week Method 3 will take a month

maxirmx commented 1 month ago

There is one argument for approach 3 https://github.com/tamatebako/tebako/issues/154 will require similar functionality to mount a second instance of memfs

ronaldtse commented 1 month ago

I agree with 3.

maxirmx commented 1 month ago

https://github.com/tamatebako/libdwarfs/issues/115