How can I prevent capistrano from overwriting files uploaded by users to their own folders?

I use Capistrano and git to deploy a RoR application. I have a folder in which each user has his own folder. When a user downloads or saves a file, it is saved in their own folder.

When I deploy new versions of code on the server, user files and folders are overwritten by what is on my dev machine.

Is there a way to ignore some folders in capistrano like in git? This post http://www.ruby-forum.com/topic/97539 - suggests using symbolic links and saving user files in a shared folder. But this is an old post, so I wonder if there is a better way to do it now.

Also, does anyone know any good screencasts / tutorials to recommend using RoR + git + capistrano?

Thanks.

+7
git ruby-on-rails capistrano
source share
2 answers

You must move user folders outside of the Capistrano releases directory. The usual approach is for Capistrano to create symbolic links to directories that must be preserved in all deployments.

Here is an example from my Rails blog application config/deploy.rb , in which files for upload in blog posts and images used in posts are stored in the shared directory:

 after :deploy, 'deploy:link_dependencies' namespace :deploy do desc <<-DESC Creates symbolic links to configuration files and other dependencies after deployment. DESC task :link_dependencies, :roles => :app do run "ln -nfs #{shared_path}/public/files #{release_path}/public/files" run "ln -nfs #{shared_path}/public/images/posts #{release_path}/public/images/posts" end end 
+10
source share

It is too late, but I ran into this problem. I use rails 5 and capistrano 3.6. I solved this problem by creating a symlink for the shared folder.

Perhaps you already have this line in your deploy.rb

 set :linked_dirs, %w{bin log tmp/pids tmp/cache tmp/sockets vendor/bundle} 

If you want to save user images in the public / images / user _images and symbolically bind them to the shared folder, add the folder name with a space (for example :):

 set :linked_dirs, %w{bin log tmp/pids tmp/cache tmp/sockets vendor/bundle public/images/user_images} 

Now run cap production deploy and you can access the images in the shared folder.

0
source share

All Articles