npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

ghost-google-cloud-storage-rhk

v1.2.1

Published

A simple plugin to add Google Cloud Storage support for Ghost Blog

Downloads

11

Readme

Ghost Google Cloud Storage Plugin

A simple plugin to add Google Cloud Storage support for a Ghost Blog

Installation

cd /var/www/ghost # or wherever you ran ghost-cli, this is your ghost base directory
npm install --save ghost-google-cloud-storage

Note that if you do not have a package.json file in your ghost base directory, this will warn. You do not need to add one, the node_modules directory will be created and populated either way. You can create one by running npm init.

Create storage module

# This assumes that you are operating on your production environemnt, change the following variable if necessary.
export GHOST_ENVIRONMENT=production
# Your content path will be determined by your config file: https://docs.ghost.org/v1.0/docs/config#section-paths
# You can run the jq command to get it for you
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-google-cloud-storage');
EOL

Configuration

Create a bucket in your google cloud project. In the storage settings you will find your project id as x-goog-project-id, after that you need to go to your API Credentials settings and create a Service account key, choosing JSON as the key type.

Add this key on your root ghost folder or any folder you want.

Add a storage block to your config.${GHOST_ENVIRONMENT}.json as below:

"storage": {
    "active": "gcloud",
    "gcloud": {
        "projectId": "Your_project_id",
        "key": "Your_key_path",
        "bucket": "Your_bucket_name",
        "assetDomain": "domain-for-bucket.example.com",
        "insecure": true,
        "maxAge": "2678400"
    }
}

Notes:

  • For the key path, if it is in the ghost root directory, just use the name of the file. Otherwise use an absolute path.
  • The assetDomain is an optional config entry, and 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. Here is a list of workarounds. Pair with the "insecure": true option to use bare http URLs.
  • The insecure config is also optional, and defaults to false. Set to true if you are using a custom asset domain, and do not have https configured.
  • The maxAge is an optional config entry, and is only required if you want to set the cache-control's max age property. It defaults to 31 days (in seconds). This 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. It can be overridden to set the max age to something else, smaller if you would like cache entries to be revalidated quicker, larger if you would like the cache entries to last for longer than 1 month.

Verify Ghost config

ghost stop
ghost run

You will see some logs or an error if the install was not successful. Fix any errors and then run ghost run again until you see the Ghost boot log entry.

Restart ghost

ghost start

Here is a transcript of the above, with errors


user@ghost:/var/www/ghost$ ghost stop
ghost run
Running sudo command: systemctl stop ghost_example-com
✔ Stopping Ghost
user@ghost:/var/www/ghost$ ghost run
The `ghost run` command is used by the configured Ghost process manager and for debugging. If you're not running this to debug something, you should run `ghost start` instead.
Running sudo command: node current/index.js
[2017-10-02 16:18:26] ERROR

NAME: IncorrectUsageError
CODE: MODULE_NOT_FOUND
MESSAGE: We have detected an error in your custom storage adapter.

level:critical

IncorrectUsageError: We have detected an error in your custom storage adapter.
    at new IncorrectUsageError (/var/www/ghost/versions/1.10.0/node_modules/ghost-ignition/lib/errors/index.js:79:23)
    at Object.getStorage (/var/www/ghost/versions/1.10.0/core/server/adapters/storage/index.js:43:19)
    ...

# fix the issue and retry

user@ghost:/var/www/ghost$ ghost run
The `ghost run` command is used by the configured Ghost process manager and for debugging. If you're not running this to debug something, you should run `ghost start` instead.
Running sudo command: node current/index.js
[2017-10-02 18:31:58] INFO Ghost is running in production... 
[2017-10-02 18:31:58] INFO Your blog is now available on http://example.com/ 
[2017-10-02 18:31:58] INFO Ctrl+C to shut down 
[2017-10-02 18:31:58] INFO Ghost boot 11.834s 
^C[2017-10-02 18:32:02] WARN Ghost has shut down 
[2017-10-02 18:32:02] WARN Your blog is now offline 
user@ghost:/var/www/ghost$ ghost start
✔ Validating config
Running sudo command: systemctl start ghost_example-com
✔ Starting Ghost
You can access your blog at http://example.com

Contributors

  • thombuchi
  • prenaudin
  • gcochard
  • zackify