Asset deployment into shared volumes (rails & nginx)

Hi there,

I googled a lot but didn’t find an answer / best practice for my issue. It would be great I someone could give me advice! :slightly_smiling_face:

Imagine a docker swarm with a self built rails image and a nginx server:

services:
  app:
  [...]
   volumes:
     - assets:/var/www/app/public/assets/
 nginx:
  [...]
    volumes:
     - assets:/var/www/app/public/assets
volumes:
  assets:

The asset compilation happens while the app image is being built. I want to share the assets from the app image with nginx. This works fine in general but it turns out that the assets were copied initially into the named volume but don’t get updated as I deploy new app versions.

As soon as I deploy a new version of the app image I want the assets volume to be replaced entirely by the content of “/var/www/app/public/assets/” - every time, not just initially.

I think I could shut down the whole swarm and wipe the volume at each deployment but this is a very bad deployment strategy I’d like to avoid.

Thank you so much!
Björn