Ghost adapter to store images into Google Cloud Storage
npm install ghost-gcp-storage-adapterGoogle Cloud Storage API is enable in APIs & Services > LibraryIAM & Admin > Service AccountsIAM & Admin > Service Accounts > > Actions > Manage Keys > Add Key credentials.jsonconfig.production.json or config.development.json):bash
cd /your/ghost/instalation/folder
`2. Create the
adapters/storage folder inside the content folder:
`bash
mkdir -p content/adapters/storage
`3. Install this package via NPM:
`bash
npm i ghost-gcp-storage-adapter
`4. Copy the installed package into
content/adapters/storage:
`bash
cp -r node_modules/ghost-gcp-storage-adapter content/adapters/storage/ghost-gcp-storage-adapter
`5. Copy your
credentials.json file into content/adapters/storage/ghost-gcp-storage-adapter7. Add the following configuration to your
config.production.json file:
`json
"storage": {
"active": "ghost-gcp-storage-adapter", // For images
"media": "ghost-gcp-storage-adapter", // For video and audio files
"files": "ghost-gcp-storage-adapter", // For other file types
"ghost-gcp-storage-adapter": {
"projectId": "",
"keyFilename": "/content/adapters/storage/ghost-gcp-storage-adapter/credentials.json",
"bucketName": ""
}
}
`Storage Configuration Options:
-
active: Controls the storage adapter for images
- media: Controls the storage adapter for video and audio files
- files: Controls the storage adapter for other file types6. Restart Ghost
$3
If you're running Ghost in Docker, follow these steps:1. Clone and prepare the adapter:
`bash
Clone this repository
git clone https://github.com/vcgtz/ghost-gcp-storage-adapter.git
cd ghost-gcp-storage-adapterInstall dependencies
npm install
`2. Update your
docker-compose.yml to mount the necessary volumes:
`yaml
version: '3'
services:
ghost:
image: ghost:5-alpine
volumes:
# Mount config.production.json
- ./config.production.json:/var/lib/ghost/config.production.json
# Mount the storage adapter
- ./ghost-gcp-storage-adapter:/var/lib/ghost/content/adapters/storage/ghost-gcp-storage-adapter
# Mount credentials.json (ensure it's in your project directory)
- ./credentials.json:/var/lib/ghost/content/adapters/storage/ghost-gcp-storage-adapter/credentials.json
// ... other configurations ...
`3. Ensure your
config.production.json includes the storage configuration:
`json
{
// ... other configurations ...
"storage": {
"active": "ghost-gcp-storage-adapter", // For images
"media": "ghost-gcp-storage-adapter", // For video and audio files
"files": "ghost-gcp-storage-adapter", // For other file types
"ghost-gcp-storage-adapter": {
"projectId": "",
"keyFilename": "/var/lib/ghost/content/adapters/storage/ghost-gcp-storage-adapter/credentials.json",
"bucketName": ""
}
}
}
`4. Start your Docker containers:
`bash
docker-compose up -d
`Note: Make sure the file permissions are correct and the credentials.json file is accessible within the container.
$3
If you want to contribute or test this adapter, you can use it locally by following the next instructions:1. Follow the same steps to configure Google Cloud Storage
2. Fork this repo
3. Clone your fork in your computer
4. Install Ghost locally (Instructions)
5. In the folder where you installed Ghost, install the adapter locally
`bash
cd ghost_folder/
npm install /path/to/your/forked/repo
`
6. Create the adapters/storage folder inside the content folder:
`bash
mkdir -p content/adapters/storage
`
7. Copy the installed package into content/adapters/storage:
`bash
cp -r node_modules/ghost-gcp-storage-adapter content/adapters/storage/ghost-gcp-storage-adapter
`
8. Copy your credentials.json file into content/adapters/storage/ghost-gcp-storage-adapter
9. Stop Ghost and running it in development mode by using:
`bash
NODE_ENV=development ghost run
``With this you'be able to see the logs in real time and test and debug this package.