Thoughts, stories and ideas.
Photo provided by DigitalOcean.

Update 1/13/2023: Added background information about DigitalOcean Spaces.

Background

I've wanted to integrate DigitalOcean for my blog for a while and decided to try the platform since it is straightforward to use and integrate into the site. This would reduce the headaches and overhead of managing local storage inside my Droplet. Without further ado, Let's dig into the details.

DigitalOcean Spaces is a simple object storage that allows customers upload content on their cloud servers and scale up when needed. It is $5/month per 250GB of content. Anything over that will be billed as $0.02/GiB/month. If you are interested in doing business with DigitalOcean, please sign up via my referral link here. Not sponsored by them in any capacity, but I use their products regularly for both production and training purposes.

Requirements

  • DigitalOcean account and Ghost Droplet provisioned via One-Click Install
  • DigitalOcean Spaces bucket (that is hosted on the same region as the bucket)
  • Internet connection
  • SSH terminal
  • Some knowledge of Linux (ideally, Ubuntu Server)
  • Ghost 5 (or later) instance

If you have your Ghost instance on, please stop the service before continuing this tutorial.

Droplet Instructions

  1. Open a terminal or command prompt window.
  2. Login into your Droplet via your favorite SSH client. ssh root@ip
  3. Enter any SSH password if prompted.
  4. Once you're inside, use the provided Ghost user that you are managing for your website. sudo -i -u ghost-mgr
  5. Then, navigate to the folder that contains the Ghost files. Droplets that DigitalOcean's One-Click Install has provisioned will reside in /var/www/ghost/.
  6. Next, navigate over to the current folder. cd current
  7. Inside this folder, you will need to invoke yarn add ghost-storage-adapter-s3 to install the dependency on your existing site.
  8. Now, we will need to copy the ghost-storage-adapter-s3 from the node_modules folder into the /var/www/ghost/versions/5.x.x/core/adapters/storage/s3. You will need to use sudo for this action. cp -r node_modules/ghost-storage-adapter-s3 /var/www/ghost/versions/5.x.x/core/server/adapters/storage/s3
  9. Finally, in the /var/www/ghost/ folder, edit the config.production.json and add the following snippet:

Before you start using this adapter

  • Run ghost doctor to see if there are any issues with the created folders and fix them if necessary.
  • Any assets that you've created in the past will be broken upon restart of the service.

Once you're happy with the configuration, spin back up Ghost by invoking ghost start.

If you liked this tutorial, let me know in the comments below and don't forget to subscribe to my email newsletters so that you don't miss out any new posts I publish in the future.

You’ve successfully subscribed to Rod's Adventures
Welcome back! You’ve successfully signed in.
Great! You’ve successfully signed up.
Success! Your email is updated.
Your link has expired
Success! Check your email for magic link to sign-in.