1

We are running a Ruby on Rails 5 application in a Docker Container. The container is hosted on Azure Container Apps.

We need to persist the public folder and would like to use Azure File Share for this. The share is working and accessible (test via script)

Problem is now, that with azure container apps we can't define a volume like in docker-compose in order to change the public folder directly from inside the container to outside:

    volumes:
      - "./path/to/public/folder:/app/public"

Usually I would pass the volume to docker run, but this is not possible with azure container apps.

I am no Ruby developer.

I tried to change the public folder for assets with the following How to override public folder path in Rails 4?

in config/Application.rb

config.assets.paths['public'] = File.join('/cms-share', 'public')

Sadly this is leading to an exception on startup:

 ! Unable to load application: TypeError: no implicit conversion of String into Integer
/app/config/application.rb:32:in `[]=': no implicit conversion of String into Integer (TypeError)

Thanks in advance

Mario
  • 978
  • 2
  • 11
  • 31
  • 1
    I'm not familiar with Azure, but the docs on [Storage Mounts](https://learn.microsoft.com/en-us/azure/container-apps/storage-mounts-azure-files?tabs=bash) suggest that you can mount a file share at a specific path, using the `volumeMounts` in your resource template (see step 8 under "Create the storage mount"). How are you currently mounting the share? – Robert Nubel Aug 04 '22 at 13:11

1 Answers1

0

You have missed the object you are trying to modify.

config.assets.paths
#=> ['app/assets/images', ..]

Those are assets paths and returned object is array and what you needed to modify is some rails path object, which return other object that can be modified.

config.paths['public']
=>
#<Rails::Paths::Path:0x0000000113acbca0
 @autoload=false,
 @autoload_once=false,
 @current="public",
 @eager_load=false,
 @exclude=nil,
 @glob=nil,
 @load_path=false,
...

Be attentive that the second one, does not have anything about assets it is just config.paths

config.paths['public'] = File.join('/cms-share', 'public')

This code will solve your problem with changing default public path.

zhisme
  • 2,368
  • 2
  • 19
  • 28