basecamp / kamal

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

Wrong permissions on volumes #897

Open alec-c4 opened 1 month ago

alec-c4 commented 1 month ago

Hey! There are problem with permissions in kamal. I've added volume

ssh:
  user: alec

####################

volumes:
  - ./storage:/rails/public/uploads:rw

in my deploy.yml file and got a problem with permissions:

SCR-20240730-bilf

As you see - I've configured kamal to use user alec, but volume was created by/for root. It cause problems like this:

SCR-20240730-bjkb
igor-alexandrov commented 1 month ago

Alex, this is now a problem of Kamal. You cannot change permissions of the volume, while mounting it. All available options can be found here: https://docs.docker.com/storage/volumes/.

Maybe you are missing chown command in your Dockerfile RUN chown rails:rails /rails.

alec-c4 commented 1 month ago

Maybe you are missing chown command in your Dockerfile RUN chown rails:rails /rails.

@igor-alexandrov nope :( I've fixed this issue by another way:

$ mkdir ./storage
$ chown -R alec:alec ./storage

anyway - it is a workaround, I think storage directory should be created automatically with setup command and owner should be set as a deploy-user from deploy.yml

igor-alexandrov commented 1 month ago

Maybe I didn't got you right. Are you talking about incorrect permissions on the host machine or in the image?

alec-c4 commented 1 month ago

@igor-alexandrov on the host machine. I think this issue is connected with #898 because of the similar symptoms. /letsencrypt and storage folders were created with incorrect owner (root instead of alec in my case)

igor-alexandrov commented 1 month ago

Ok, I was wrong in my initial answer.

I am not sure that this is a responsibility of Kamal to make sure that the volume exists on the host machine. @djmb what do you think? I make a PR if you will decide to go with it.