ghost-gstorage-plugin v1.0.2
📝 Table of Contents
- 📝 Table of Contents
- 🧐 About
- 🏁 Getting Started
- ⚙️ Configuration
- ⛏️ Built Using
- ✍️ Authors
- 🎉 Acknowledgements
🧐 About
The ghost-gstorage-plugin
is a storage adapter for Ghost CMS that allows you to store your media files on Google Cloud Storage. This plugin provides a seamless way to manage and serve your media files directly from Google Cloud, ensuring high availability and scalability.
🏁 Getting Started
These instructions will help you set up the ghost-gstorage-plugin
on your Ghost blog.
Prerequisites
Before you begin, ensure you have met the following requirements:
- You have a Google Cloud account.
- You have created a Google Cloud Storage bucket.
- You have a service account key JSON file for authentication.
Installing
Navigate to your Ghost installation directory:
cd /var/www/ghost
Install the plugin:
npm install --save ghost-gstorage-plugin
Create the storage module:
export GHOST_ENVIRONMENT=production export CONTENT_PATH=$(jq -r '.paths.contentPath // "."' config.${GHOST_ENVIRONMENT}.json) mkdir -p ${CONTENT_PATH}/adapters/storage/gcloud cat > ${CONTENT_PATH}/adapters/storage/gcloud/index.js << EOL 'use strict'; module.exports = require('ghost-gstorage-plugin'); EOL
⚙️ Configuration
Create a bucket in your Google Cloud project. Note your project ID and create a service account key in JSON format.
Add the key to your Ghost root directory or any preferred location.
Update your
config.production.json
with the following configuration:"storage": { "active": "gcloud", "gcloud": { "projectId": "<your-project-id>", "bucket": "<your-bucket-name>", "key": "<path-to-your-service-account-key.json>", "assetDomain": "<your-asset-domain>", "uploadFolderPath": "<your-upload-folder-path>", "insecure": <true-or-false>, "maxAge": "<cache-control-max-age-in-seconds>" } }
- projectId: Your Google Cloud project ID.
- key: Path to your service account key JSON file. If it's in the Ghost root directory, just use the file name; otherwise, use an absolute path.
- bucket: Your Google Cloud Storage bucket name.
- assetDomain: Optional custom domain for your bucket. This is only required if you want to use a custom domain for your cloud storage bucket. Note that these instructions only allow for HTTP, not HTTPS, as the storage servers do not present a custom certificate for your domain.
- uploadFolderPath: The path within your bucket where files will be uploaded.
- insecure: Set to true if using a custom domain without HTTPS. This config is optional and defaults to false.
- maxAge: Cache control max-age in seconds. This is optional and defaults to 31 days (in seconds). It is desirable if you will not be deleting and re-uploading the same file multiple times, and will reduce your bandwidth usage when paired with a CDN.
Verify your Ghost configuration:
ghost stop ghost run
You will see some logs or an error if the install was not successful. Fix any errors and rerun until successful.
Restart Ghost:
ghost start
⛏️ Built Using
- @google-cloud/storage - Google Cloud Storage Node.js Client
- Ghost - The open-source headless Node.js CMS
✍️ Authors
- Ayush Naik - Initial work
🎉 Acknowledgements
- Thanks to the Ghost community for their support and contributions.