user1961082
user1961082

Reputation: 1035

Symfony2 + Capifony

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, "[email protected]: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"

Upvotes: 2

Views: 1031

Answers (2)

gezpage
gezpage

Reputation: 451

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.

Upvotes: 1

eux
eux

Reputation: 71

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?

Upvotes: 0

Related Questions