title: Images not showing after deploy with Capistrano and ActiveStorage
body: <p>I've already running Spree on a Digital Ocean's server, but every time I deploy a new version, I'm getting not found for the images that have been uploaded by users on previous versions</p>
  <p>Based in related posts that I've found, it seems to be a problem in the way that I've setup symlinked dirs</p>
  <p>I tried adding <code>storage</code> dir to linked_dirs in my <code>deploy.rb</code> and released a new version running <code>cap production deploy</code>, but I'm still getting the same error</p>
  <pre><code>set :linked_dirs,  %w{log tmp/pids tmp/cache tmp/sockets vendor/bundle .bundle public/system public/uploads storage}
  </code></pre>
  <p>I don't really know if this may be working from current release onwards, but <strong>the thing is that previous images are still lost and I need to keep them after delploying a new version</strong></p>
  <p>This is my <code>Capfile</code></p>
  <pre><code># Load DSL and Setup Up Stages
  require 'capistrano/setup'
  require 'capistrano/deploy'
  
  require 'sshkit/sudo'
  
  require 'capistrano/rails/migrations'
  require 'capistrano/bundler'
  require 'capistrano/rvm'
  require 'capistrano/puma'
  require 'capistrano/nginx'
  
  install_plugin Capistrano::Puma
  
  # Loads custom tasks from `lib/capistrano/tasks' if you have any defined.
  Dir.glob('lib/capistrano/tasks/*.rake').each { |r| import r }
  </code></pre>
  <p>This is my <code>config/deploy.rb</code></p>
  <pre><code># config valid for current version and patch releases of Capistrano
  lock &quot;~&gt; 3.14.0&quot;
  
  # Change these
  server 'XXX.XX.XX.XXX', port: 22, roles: [:web, :app, :db], primary: true
  
  set :repo_url,        'git@gitlab.com:my-user/my-app-name.git'
  set :application,     'my-app-name'
  set :user,            'deploy'
  set :puma_threads,    [4, 16]
  set :puma_workers,    0
  
  # Don't change these unless you know what you're doing
  set :pty,             true
  set :use_sudo,        false
  set :deploy_via,      :remote_cache
  set :puma_bind,       &quot;unix://#{shared_path}/tmp/sockets/#{fetch(:application)}-puma.sock&quot;
  set :puma_state,      &quot;#{shared_path}/tmp/pids/puma.state&quot;
  set :puma_pid,        &quot;#{shared_path}/tmp/pids/puma.pid&quot;
  set :puma_access_log, &quot;#{release_path}/log/puma.error.log&quot;
  set :puma_error_log,  &quot;#{release_path}/log/puma.access.log&quot;
  set :ssh_options,     { forward_agent: true, user: fetch(:user), keys: %w(~/.ssh/id_rsa) }
  set :puma_preload_app, true
  set :puma_worker_timeout, nil
  set :puma_init_active_record, true  # Change to false when not using ActiveRecord
  
  
  ## Linked Files &amp; Directories (Default None):
  set :linked_files, %w{config/secrets.yml config/database.yml}
  set :linked_dirs,  %w{log tmp/pids tmp/cache tmp/sockets vendor/bundle .bundle public/system public/uploads storage}
  
  namespace :puma do
    desc 'Create Directories for Puma Pids and Socket'
    task :make_dirs do
      on roles(:app) do
        execute &quot;mkdir #{shared_path}/tmp/sockets -p&quot;
        execute &quot;mkdir #{shared_path}/tmp/pids -p&quot;
      end
    end
  
    before :start, :make_dirs
  end
  
  namespace :deploy do
    desc &quot;Make sure local git is in sync with remote.&quot;
    task :check_revision do
      on roles(:app) do
        unless `git rev-parse HEAD` == `git rev-parse origin/master`
          puts &quot;WARNING: HEAD is not the same as origin/master&quot;
          puts &quot;Run `git push` to sync changes.&quot;
        end
      end
    end
  
    desc 'Initial Deploy'
    task :initial do
      on roles(:app) do
        before 'deploy:restart', 'puma:start'
        invoke 'deploy'
      end
    end
  
    # Reload Nginx after deploy
    after 'deploy:published', 'nginx:reload'
  
    before :starting,     :check_revision
    # after  :finishing,    :precompile_assets
    after  :finishing,    :cleanup
    # after  :finishing,    :restart
  end
  </code></pre>
  <p>This is my <code>config/environments/production.rb</code></p>
  <pre><code>Rails.application.configure do
    config.cache_classes = true
    config.eager_load = true
  
    # Full error reports are disabled and caching is turned on.
    config.consider_all_requests_local       = false
    config.action_controller.perform_caching = true
  
    # Disable serving static files from the `/public` folder by default since
    # Apache or NGINX already handles this.
    config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present?
  
    # Do not fallback to assets pipeline if a precompiled asset is missed.
    config.assets.compile = true
  
    # Store uploaded files on the local file system (see config/storage.yml for options).
    config.active_storage.service = :local
  
    # Use the lowest log level to ensure availability of diagnostic information
    # when problems arise.
    config.log_level = :debug
  
    # Prepend all log lines with the following tags.
    config.log_tags = [ :request_id ]
  
    config.action_mailer.perform_caching = false
  
    # Enable locale fallbacks for I18n (makes lookups for any locale fall back to
    # the I18n.default_locale when a translation cannot be found).
    config.i18n.fallbacks = true
  
    # Send deprecation notices to registered listeners.
    config.active_support.deprecation = :notify
  
    # Use default logging formatter so that PID and timestamp are not suppressed.
    config.log_formatter = ::Logger::Formatter.new
  
    if ENV[&quot;RAILS_LOG_TO_STDOUT&quot;].present?
      logger           = ActiveSupport::Logger.new(STDOUT)
      logger.formatter = config.log_formatter
      config.logger    = ActiveSupport::TaggedLogging.new(logger)
    end
  
    # Do not dump schema after migrations.
    config.active_record.dump_schema_after_migration = false
  
    Rails.application.routes.default_url_options[:protocol] = 'https'
  end
  </code></pre>
  <p>This is my <code>config/storage.yml</code></p>
  <pre><code>test:
    service: Disk
    root: &lt;%= Rails.root.join(&quot;tmp/storage&quot;) %&gt;
  
  local:
    service: Disk
    root: &lt;%= Rails.root.join(&quot;storage&quot;) %&gt;
  </code></pre>
  <p>Related:</p>
  <blockquote>
  <p><a href="https://github.com/spree/spree/issues/2754" rel="nofollow noreferrer">https://github.com/spree/spree/issues/2754</a></p>
  </blockquote>