views:

234

answers:

1

I'm sort of stuck with adding symlinks to my app on the server. I currently have the following in .gitignore:

/non-public/system/uploads/*

I basically don't want Git to store the contents of the upload directory. So far so good.

On my server, inside my deploy.rb, I have the following:

namespace :customs do
  task :symlink, :roles => :app do
    run <<-CMD
      ln -nfs #{shared_path}/system/uploads #{release_path}/non-public/system/uploads
    CMD
  end
end

after "deploy:symlink","customs:symlink"
after "deploy", "deploy:cleanup"

I want to create a symlink after each deployment for the uploads directory, but I keep getting a failed error message because the non-public/system/uploads directory doesn't exist in the git repository in the first place.

I've verified this by taking a look at the repository, and the structure /non-public/system/uploads doesn't exist because I have that set in .gitignore to ignore it.

I've looked at the Git wiki and it doesn't track directories, so I must be missing something. How do other developers symlink the uploads directory with their server?

A: 

What I'll usually do on my cap deploys is to create the directories, by doing a basic

set :deploy_to, "/this/dir"

run "mkdir -p #{deploy_to}/then/more/dirs"

after "deploy:symlink"

namespace :deploy....
  ....
  ....

then provide the run code to do some symlinks either on an after or whatever. This probably not optimal for all situations, but for the simple stuff it usually gets the job done.

nowk
Awesome thanks. The only issue I'm having now is that I think I did my symlink wrong. I used the following command -- ln -nfs shared/system/uploads current/non-public/system/uploads -- unfortunately it created a uploads directory inside of the already existing uploads directory. :(
Steve
I fiddled with deploy a bit more and now I understand symlinking and how it needs to be structured. Thanks for the guidance!
Steve