Trying to store images in my go app in deployed using dokku.

January 12, 2016 2k views
API Dokku

I’m pretty new to digital ocean and developed a Go app. The app works by fetching images from sources on the web and store them in a local directory for further serving. The app is working fine in the localhost , but when deployed using dokku , nothing happens. The app cannot seem to find the images.

I searched and found to configure persistent-storage or volume-plugin. I’m confused with this and need help.

Thanks in advance.

1 Answer

Hello, making persistent storage for images (maybe uploads from your users) on DO instance is pretty easy:

  • create some folder on the server that will hold files mkdir -p /opt/dokku/YOUR_APP_NAME/uploads
  • create/configure your app to store files (uploads) somewhere in the project PROJECT_ROOT/uploads
  • setup docker-options for you app dokku docker-options:add YOUR_APP deploy,run "-v /opt/dokku/YOUR_APP_NAME/uploads:/app/uploads"

That last command made Dokku expose PROJECT_ROOT/uploads folder to be linked to /opt/dokku/YOUR_APP_NAME/uploads on the server. So everytime the application writes something to the PROJECT_ROOT/uploads it will in fact write to the /opt/dokku/YOUR_APP_NAME/uploads outside of the container. That way your files will not be destroyed by next deploy.

Have another answer? Share your knowledge.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!