Bedrock uploads directory symlink issue

I am deploying a Bedrock website using Capistrano.

In my config/deploy.rb I have the following code:

set :linked_files, fetch(:linked_files, []).push('.env')
set :linked_dirs, fetch(:linked_dirs, []).push('web/app/uploads')

The thing is I am using Elementor on my site, it generates an important CSS file in web/app/uploads/elementor.

To include this in the deployment I added the following in my .gitignore file.


The thing is the CSS only gets deployed if I remove set :linked_dirs, fetch(:linked_dirs, []).push('web/app/uploads'), but the problem is if I remove this normal file upload will not work.

But if I include it, file upload works but not the Elementor CSS file.

What do you think I can do to make normal upload work and Elementor CSS gets deployed?

I did it by adding some commands in my deploy.rb

I added before 'deploy:symlink:shared', 'deploy:copy_elementor_files', this will call copy_elementor_files before making the symlink of uploads directory.

Then in the copy_elementor_files

namespace :deploy do
  desc 'Copy elementor files'
  task :copy_elementor_files do
    on roles(:app) do
      execute "cp -R #{fetch(:release_path)}/web/app/uploads/elementor #{shared_path}/web/app/uploads"

This will copy elementor css files from latest release to shared folder.

1 Like

Dear John,
I’m converting a standard, shared web host WordPress installation with Elementor over to a bedrock project with Elementor and your custom deployment script is interesting.

TL;DR: Is it true that your custom deploy task means to avoid manual SCP / SFTP of Elementor CSS files between production deployments?

Here is how I expect your use-case:

  1. Someone works on your production Elementor website, which creates a file; e.g., global.css, automatically at /web/app/uploads/elementor/.

  2. However, here’s a scenario: the Elementor plugin version needs to be updated on production. This means that composer.json and composer.lock of the origin Git repository are different than your current, production release. You need to re-deploy production.

  3. The way that deploy.rb is supposed to work: ‘web/app/uploads’ gets pushed to the :linked_dirs array. Everything in this array “will be symlinked into the release directory during deployment” at the hook mentioned in your solution:

  1. However, please confirm, this does not match your experience; instead, if you re-deploy production, your new release folder will not contain the web/app/uploads/elementor/global.css file?

  2. To resolve this, your custom :copy_elementor_files task in deploy.rb uses the deploy:symlink:shared hook to copy Elementor uploads from the current release into the shared folder. This means that you do not need to remember to manually SCP / SFTP your /web/app/uploads/Elementor/ directory before / after each deployment.

Kind regards,

Edit: Add note about being restricted to a shared web host.