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

@abstractvector/ghost-storage-s3

v0.1.0

Published

S3-compatible storage adapter for the Ghost blogging platform

Downloads

47

Readme

Ghost S3 Storage Adapter

A storage adapter for the Ghost blogging platform to support AWS S3 compatible storage backends.

WARNING: This is pre-production code and still under active development. Use at your own risk.

Installation

Based on the Ghost config documentation, to install a custom storage adapter the file needs to be placed in content/adapters/storage, relative to the Ghost project root.

Option 1: Copy the files

This is the simplest and works well in a non-Docker install.

npm run build
mkdir -p ./content/adapters/storage
cp -r ./lib ./content/adapters/storage/s3

Option 2: Bind mount the files (Docker)

If you are running Ghost with Docker, the easiest option is to bind mount the relevant S3 storage adapter JavaScript file directly into the path where Ghost expects to find it.

The advantage of this approach is that no changes need to be made to the underlying Docker image.

To do this, run npm run build to generate the adapter file which can then be found in ./lib/index.js.

Here is a sample docker-compose.yaml file modified with the bind mount:

services:
  ghost:
    image: ghost:latest
    # ...
    volumes:
      - /path/to/Ghost-Storage-S3/lib/index.js:/var/lib/ghost/content/adapters/storage/s3/index.js

Configuration

Defining configuration variables

Configuration variables can be specified in one of two ways:

  1. In the Ghost JSON configuration file (config.production.json)
  2. Via environment variables to override the Ghost configuration

Option 1: Ghost configuration file

You'll need to add a new section in your config.production.json file as follows:

// ...
  "adapters": {
    "storage": {
      "active": "s3",
      "s3": {
        "accessKeyId": "...",
        "secretAccessKey": "...",
        "region": "...",
        "bucket": "...",
        // ...
      }
    }
  }
// ...

Option 2: Environment variables

Ghost supports overriding the runtime configuration using environment variables - this is particularly useful in a Docker installation.

The required format is to represent the JSON nesting structure using two underscores for each nested level (i.e. __), for example the following docker-compose.yaml excerpt:

services:
  ghost:
    image: ghost:latest
    # ...
    environment:
      adapters__storage__active: s3
      adapters__storage__s3__accessKeyId: 1234567890
      adapters__storage__s3__secretAccessKey: pLMnrK86BLbaeLrCIS62DiFLGVrbnxMgJiVWmWwN
      adapters__storage__s3__region: us-east-1
      adapters__storage__s3__bucket: your-bucket-name

Sample configurations

Regardless of which S3-compatible storage provider you choose, the following configuration variables are always required:

| Configuration | Example | | --------------- | ------------------------------------------ | | accessKeyId | 1234567890 | | secretAccessKey | pLMnrK86BLbaeLrCIS62DiFLGVrbnxMgJiVWmWwN | | region | us-east-1 | | bucket | your-bucket-name |

Below are some examples for the additional configuration you need for various S3-compatible storage providers. These should be provided in addition to the mandatory configuration variables above.

Backblaze B2

| Configuration | Required | Example | | ------------- | -------- | ----------------------------------------------------- | | endpoint | Yes | https://s3.us-west-002.backblazeb2.com | | assetUrl | No | https://f002.backblazeb2.com/file/your-bucket-name/ |

Linode

| Configuration | Required | Example | | ------------- | -------- | ------------------------------------------------------- | | endpoint | Yes | https://us-east-1.linodeobjects.com | | assetUrl | No | https://your-bucket-name.us-east-1.linodeobjects.com/ |