Servers

Using symbolic links

Public folder

If it's acceptable to serve your files from your public directory, you can re-use the public/system folder which is already auto-symlinked to shared/system on each deploy. The down-side of doing this is that it bypasses your application and your files get served directly by Nginx without security.

Alternatively, you can use deploy hooks to create the symbolic link. Also, you can use $STACK_BASE for your stack base path (e.g. $STACK_BASE/shared/uploads) for your deploy hook script.

To create the symbolic link, your deploy hook script could contain this:

mkdir -p $STACK_BASE/shared/uploads
chown nginx:app_writers $STACK_BASE/shared/uploads
rm -rf $STACK_PATH/uploads
ln -nsf $STACK_BASE/shared/uploads $STACK_PATH/uploads

The reason we run rm -rf on the $STACK_PATH/uploads directory is due to the way that the ln command works. When you issue the ln command, it places a link to the source directory inside the target directory, so we have to remove the directory before creating the symbolic link.

The deploy hook would look like this:

production:
    after_symlink:
      - source: /.cloud66/my_script.sh
        destination: /tmp/my_script.sh
        target: rails
        execute: true
        sudo: true
        apply_during: all
        run_on: all_servers
Previous
Setting permissions for writing to web servers