How to enable s3 storage for ghost inside docker

First create your docker compose file to enable docker

services:
  ghost:
    image: ghost:5
    restart: always
    volumes:
      - ./data/config.production.json:/var/lib/ghost/config.production.json
      - ./data/storage:/var/lib/ghost/content/adapters/storage
    ports:
      - 3100:2368
    environment:
      # see https://ghost.org/docs/config/#configuration-options
      database__client: mysql
      database__connection__host: xxx
      database__connection__user: root
      database__connection__password: xxx
      database__connection__database: ghost
      url: https://seungyu.cn
    deploy:
      resources:
        limits:
          cpus: '0.2'
          memory: 500M
        reservations:
          cpus: "0.0001"
          memory: 10M

Secondly, configure your configure.xxx.json as your preference, but inside the config, should have a block for the storage. Configure with your s3 config. Like:

{
  "storage": {
    "active": "s3",
    "s3": {
      "accessKeyId": "xxx",
      "secretAccessKey": "xxx",
      "region": "ap-xxx",
      "bucket": "xxxx",
      "endpoint": "xxxx"
    }
  }
}

Then Inside the data folder on the host, ./data, clone this repo git@github.com:abstractvector/Ghost-Storage-S3.git. Build:

cd Ghost-Storage-S3
npm install
npm run build

Previous step will generate one file we need, which is located lib/index.js. Now we need create one folder in under ./data with name s3. This should be same with the one we configured in storage.s3.

cd ..
mkdir -p s3 # same name with configured under storage block
cp Ghost-Storage-S3/lib/index.js s3/index.js

Last, we need restart the container. That should work. Try post with image, check on your s3 provider to verify.

豫ICP备18015035号-1