4
votes

Every time I upload images it goes to public/images/upload then when I run a cap deploy they get erased since it creates a new current directory.

How do I instruct Capistrano to move the files in public/images/upload to the shared/images/ then symlink those images to the current(new) release ?

after "deploy:update_code", "deploy:symlink_shared"
after "deploy:restart", "deploy:cleanup"

    namespace :deploy do
      task :restart do
        run "touch #{current_path}/tmp/restart.txt"
      end

      desc "Symlink shared configs and folders on each release."
      task :symlink_shared do
        run "ln -nfs #{shared_path}/images/upload #{release_path}/public/images/uploads"
      end
    end
1

1 Answers

3
votes

Have try to expand shared directory list?

#deploy.rb
set :shared_children, shared_children + %w{public/images/uploads}

Edit : Remove you code and set shared_children variable. After that make a cap deploy:setup so that updated your shared dir.