Trying to store images in my go app in deployed using 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.

Submit an answer

This textbox defaults to using Markdown to format your answer.

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

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

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.