Setting Up Ghost to Use DigitalOcean Spaces Storage Integration
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
- Open a terminal or command prompt window.
- Login into your Droplet via your favorite SSH client.
ssh root@ip
- Enter any SSH password if prompted.
- Once you're inside, use the provided Ghost user that you are managing for your website.
sudo -i -u ghost-mgr
- 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/
. - Next, navigate over to the
current
folder.cd current
- Inside this folder, you will need to invoke
yarn add ghost-storage-adapter-s3
to install the dependency on your existing site. - Now, we will need to copy the
ghost-storage-adapter-s3
from thenode_modules
folder into the/var/www/ghost/versions/5.x.x/core/adapters/storage/s3
. You will need to usesudo
for this action.cp -r node_modules/ghost-storage-adapter-s3 /var/www/ghost/versions/5.x.x/core/server/adapters/storage/s3
- Finally, in the
/var/www/ghost/
folder, edit theconfig.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.