Error while trying to install a custom storage adapter (Docker)

Hello! I’m trying to build a Docker image of Ghost alongside a pre-configured custom storage adapter. I’ve been trying for many iterations and currently with version 2.25.9 (both regular and alpine).

To install the adapter, I’m using the standard way (all adapters repositories have a variant of this). Here’s a sample Dockerfile:

FROM ghost:2.25.9-alpine
RUN npm install --production --loglevel=error --no-save ghost-digitalocean
RUN mv node_modules/ghost-digitalocean core/server/adapters/storage
RUN set -ex; \
  su-exec node ghost config ghost-digitalocean; \
  su-exec node ghost config storage.ghost-digitalocean.key $DO_KEY; \
  su-exec node ghost config storage.ghost-digitalocean.secret $DO_SECRET; \
  su-exec node ghost config storage.ghost-digitalocean.region $DO_REGION; \
  su-exec node ghost config storage.ghost-digitalocean.bucket $DO_BUCKET; \
  su-exec node ghost config storage.ghost-digitalocean.spaceUrl $DO_SPACE_URL; \
  su-exec node ghost config storage.ghost-digitalocean.subFolder $DO_SUBFOLDER; \
  su-exec node ghost config storage.ghost-digitalocean.endpoint $DO_ENDPOINT;

After building the image, the container won’t run. When checking the logs, here’s what I get:

    throw err;

Error: Cannot find module 'ghost-ignition'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15)
    at Function.Module._load (internal/modules/cjs/loader.js:562:25)
    at Module.require (internal/modules/cjs/loader.js:690:17)
    at require (internal/modules/cjs/helpers.js:25:18)
    at Object.<anonymous> (/var/lib/ghost/versions/2.25.9/index.js:5:13)
    at Module._compile (internal/modules/cjs/loader.js:776:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:787:10)
    at Module.load (internal/modules/cjs/loader.js:653:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
    at Function.Module._load (internal/modules/cjs/loader.js:585:3)

Now, besides checking the logs I’ve also checked the container’s file system and I am able to see:

  • The config file is correct;
  • The ghost-digitalocean module is within Ghost’s node_modules folder;
  • The ghost-digitalocean module is copied to versions/2.25.9/core/server/adapters/storage.

Other than that, I also compared the original package.json initially available within Ghost’s folder with the same package.json after running npm to install the custom adapter and they are identical.

And to add to that, I tried something crazy:

In my local machine, I created a new folder, ran npm init and then installed ghost-digitalocean.

Then, I created a new Dockerfile with the following:

FROM ghost:2.25.9
COPY src/node_modules/ /var/lib/ghost/versions/2.25.9/node_modules/
COPY src/node_modules/ghost-digitalocean/ /var/lib/ghost/versions/2.25.9/core/server/adapters/storage/digitalocean/

And believe it or not it worked. The container runs. Sure, this is very hacky and I certainly don’t want to keep generating the image this way.

There is probably some basic concept that I’m not aware of. But unfortunately, I do not now Node.js or Ghost internals to figure this one out.

Does anybody here ran in this situation before? Is there anywhere else I can go look for logs or more information on why it isn’t running?

Appreciate any help. Thanks.