When using gem v2.3.6 or higher, the Brightbox deployment gem can be configured to auto install any apt packages that your app needs. This is done before your gems are installed, so you can specify any packages that your gems depend on here as well.
So, to get your packages installed automatically, list them in
config/deploy.rb using the Capistrano
depends mechanism. For example:
depend :remote, :apt, "libxml2-dev" depend :remote, :apt, "libxslt1-dev"