At Firmhouse, we're building Intercity Next. An open source hosting management panel for Ruby on Rails that hosts apps on servers of your choice. Intercity Next uses Dokku under the hood Dokku. Dokku runs apps in Docker containers.
There are a few things to think about when running apps in Docker containers. One of them is that you have no persistent file storage in between deploys. Having no persistent storage causes every app deploy to remove all user uploaded content. Say goodbye to those avatars uploaded by Paperclip or Carrierwave! Luckily, you can solve that with the docker-options feature in Dokku.
I want Paperclip to be able to store user uploaded content and keep it in between deploys. The default Paperclip storage directory is $RAILS_ROOT/public/system. So I want to make this directory persistent. This is how I do that:
First I create a storage directory on the host server:
Then I tell Dokku to launch my app container with that directory from the host system mounted in my app:
Dokku will now use this -v option for all new deploys.
The only thing to do now refresh the currently running app containers:
Done! Persistent storage for your app without needing an external storage service.
If you have any questions or comments, please let me know! You can reach me on Twitter via @michiels or send me an email at mailto:michiel@firmhouse.com.
Trusted by the brands you know.
We're home to the brands that inspire you. Join them in the movement to change how we consume products.