Search code examples
rubyrakeweb-deploymentfile-permissions

Deployment with Rake Causing Image Permission Errors (600)


I'm deploying my website to my server with Rake for the first time and I've run into a slight issue.

RAKEFILE

desc 'Deploying the website...'
task :deploy do
  puts 'Deploying to server.com'
  user = 'user'
  server = 'server.com'
  path = 'server.com/html'
  sh "rsync -rtzh --delete _site/ #{user}@#{server}:#{path}"
  puts 'Fin!'
end

When I run rake deploy and enter the password, everything successfully uploads to the server; except some of the images aren't loading on the page. I had a look, and the files are definitely on the server, but I think the problem lies with the permissions of these images:

enter image description here

When I upload over FTP the files are set to 755 and they're visible on the site. When I do it with Rake, they're set to 600 and hidden.

Is it possible to set them to 755 or 644 or any idea why this is happening?

I could change the permissions for each and every image, but isn't the most elegant solution.

Any help is appreciated. Thanks!


Solution

  • Rake isn't really your problem here. Rake doesn't know anything about uploading files or setting permissions; it just runs the commands as defined in the task.

    The actual file upload is happening via rsync. According to the rsync man page, you should be able to use the option -p (AKA --perms) to set the files copied to the destination server to have the same permissions as the source files.