basecamp / kamal

Deploy web apps anywhere.
https://kamal-deploy.org
MIT License
9.38k stars 357 forks source link

Add volumes through `--mount` #839

Closed ZipoKing closed 3 weeks ago

ZipoKing commented 3 weeks ago

Is there a way to add another option beside files, directories and volumes (e.g. called mounts) which will allow to attach volumes with more advanced options. What we want to achieve is to mount multiple CIFS/NFS volumes so application will have access to those.

According to Docker documentation (https://docs.docker.com/storage/volumes/) it is not possible through volumes as it sys:

If you need to specify volume driver options, you must use --mount

djmb commented 3 weeks ago

Is this for an accessory? You can set arbitrary options for the docker run command with the options field -

accessories:
  my_accessory:
    ...
    options:
      mount: ....
ZipoKing commented 3 weeks ago

There are several NFS/CIFS volumes which are being used by Rails app: one is NAS for active storage, second is Windows share from accounting software etc. So it's more as app volume rather than accessory one. I know there is workaround where I can create Docker volumes directly on the host and then point at them within Kamal config but I think it will be better solution to have whole setup in one file rather than referencing to externally created ones. I see that there are some mentions for mount in Kamal test files (https://github.com/basecamp/kamal/blob/main/test/commands/app_test.rb) but I am not able find any docs about that (especially when multiple --mount will have to be used to manage multiple volumes).

I am not sure if it can even work with existing volumes which when defined as YAML object can result in --mount option rather than --volume (when string provided).

djmb commented 3 weeks ago

You can also set them on roles and if you provide an array as the value, then you can set multiple ones:

servers:
  web:
    hosts:
      - 1.1.1.1
    options:
      mount:
        - <mount1>
        - <mount2>

If you have multiple roles, right now you'll need to specify the options for each separately. We should add the ability to set options in the root of the config though to avoid that.

Let me know if this does what you need!

Regarding the docs, https://github.com/basecamp/kamal/pull/828 should improve those. Once its released (next week hopefully), we'll have documentation of all configuration settings on kamal-site.org

ZipoKing commented 3 weeks ago

It will work perfectly, thank you