2

I'm trying to configure Capifony to deploy to my remote servers. What I would like to know is if my uploads directory should be within .gitignore? When running cap development depoy I'm getting a symlink error:

executing "ln -nfs /var/www/dev.xyz.co.uk/shared/web/uploads /var/www/dev.xyz.co.uk/releases/20130313103147/web/uploads"

*** [err :: x.xx.xx.xxx] ln:
*** [err :: x.xx.xx.xxx] failed to create symbolic link `/var/www/dev.xyz.co.uk/releases/20130313103147/web/uploads'
*** [err :: x.xx.xx.xxx] : No such file or directory
*** [err :: x.xx.xx.xxx] 

Is this because /web/uploads is within .gitignore so it'll never be pulled from git in order to symlink?

Do I need to clone my repository first on the remote server or does Capifony do this for me?

deploy.rb below:

set :stage_dir, 'app/config/deploy' # needed for Symfony2 only
set :stages, %w(production staging development)
require 'capistrano/ext/multistage'

set :application, "xyz.co.uk"
set :user, "root"  # The server's user for deploys

set :scm,         :git
set :repository, "git@github.com:test/#{application}.git"
set :keep_releases,  3
set :use_sudo,       false
set :shared_files,      ["app/config/parameters.yml"]
set :shared_children,   [app_path + "/logs", web_path + "/uploads", "vendor"]
set :use_composer, true
set :update_vendors, true
set :dump_assetic_assets, true
set :deploy_via, :copy

logger.level = Logger::MAX_LEVEL

development.rb below:

server 'x.xx.xx.xxx', :app, :web, :primary => true
ssh_options[:port] = xxxx
ssh_options[:forward_agent] = true
set :deploy_to, "/var/www/xyz.co.uk/"
set :symfony_env_prod, "dev"
user1961082
  • 1,015
  • 17
  • 41

2 Answers2

1

There are a couple of ways to achieve this.

Commit the empty folder to git:

Create the file /web/uploads/.gitignore with the following contents:

!.gitignore

This will allow the directory to be committed to the repository but all content will be ignored. It will create en empty uploads folder on every deployment.

Create uploads as a shared folder for all deployments

This method has the advantage of preserving your uploads between deployments - probably what you want.

In your deploy.rb create a "firstdeploy" task which only gets executed for the initial deployment, and create the directory at this stage:

run "mkdir -p #{shared_path}/web/uploads"

In your deploy config configure it as a shared path like so

set :web_path,   "web"
set :shared_children, [web_path + "/uploads"]

I posted my deploy script here if it helps.

gezpage
  • 441
  • 4
  • 11
  • Thanks for your comments. I've created the uploads directory manually at /var/www/dev.xyz.co.uk/shared/web/uploads so I don't think I'll need to create the firstdeploytask. For some reason though it won't create the symlink?! – user1961082 Mar 13 '13 at 13:04
  • I've also updated my initial question to show my deploy.rb and development.rb scripts. On the development server I usually use a specific SSH key to git pull for my other sites on there which aren't using Capifony. This has a different email and password for github than my local machine. – user1961082 Mar 13 '13 at 13:06
  • @gezpage: I'm having the same problem (`failed to create symbolic link /home/ubuntu/myapp/releases/20130323155737/web/uploads`). I've followed your advice to remove `/web/uploads` from the project-level .gitgnore file, and added the .gitignore file inside of `web/uploads`. Still the same error. Could you perhaps share the content of your project .gitgnore file? Any other ideas? – Matt C Mar 23 '13 at 16:04
0

I think you can keep it ignored as for /config/parameters.yml

but you should manually create the upload folder inside the shared folder did you do it?

eux
  • 71
  • 1
  • 7
  • Yes /var/www/dev.xyz.co.uk/shared/web/uploads/ exists on the server. - `drwxr-xr-x 2 root root 4096 Mar 12 14:21 uploads` – user1961082 Mar 13 '13 at 11:32
  • Is there anything else that needs setting up on the server? Do I need to initialise GIT on the server? I've copied my local SSH keys to the development server. – user1961082 Mar 13 '13 at 11:37
  • If I take web_path + "/uploads" out of deploy.rb then I get an error with /config/parameters.yml - `failed to create symbolic link `/var/www/dev.xyz.co.uk/releases/20130313113859/app/config/parameters.yml'` – user1961082 Mar 13 '13 at 11:40