Installation and update of integration on self-hosted

I’m using the DO droplet of Ghost and have installed the S3 storage integration (ghost-storage-adapter-s3) according to the instructions (essentially yarn install, manually copy integration, update config). This works ok.

However, on every upgrade, this breaks – the integration is not copied over, and the dependencies installed by yarn are lost as well.

I’ve tried copying the integration to the /var/www/ghost/content/adapters folder, both directly and in a storage subfolder, but ghost does not pick that up. Even if it did, that would likely not account for the missing dependencies.

Now, every upgrade, I need to manually copy over the integration, install the dependencies, run yarn update, and then restart. This is a hassle, error-prone, and leads to downtime.

Is there a better way to install an integration I have overlooked?

Try use python to make it working with subprocess.

Example:

import subprocess

def display_message(message):
    print(message)

def run_apt_update():
    try:

        process = subprocess.Popen(['sudo', 'apt', 'update'], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
        stdout, stderr = process.communicate()
        if process.returncode == 0:
            print("Command 'sudo apt update' ended with success.")
            print(stdout.decode())
        else:
            print("Command 'sudo apt update' ended with errors.")
            print(stderr.decode())
    except Exception as e:
        print(f"An error occurred: {e}")

def main():
    display_message("Starting update...")
    run_apt_update()
    display_message("Update ended.")

if __name__ == "__main__":
    main()

1 Like

Thanks for the suggestion - I guess I wasn’t completely clear, I wasn’t talking about updating the OS, but updating ghost (using ghost-cli ghost update).

I could relatively easily script that (I’d probably just use bash or zsh for that), but it seems like the wrong solution: I’d expect the use case of installing one or more integrations while keeping the ghost installation up-to-date to be a very common use case that wouldn’t need custom scripting.

E: this small bash script does the update but still results in downtime from ghost update to ghost restart which is not insignificant due to the yarn upgrade

#!/bin/bash

cd /var/www/ghost/
ghost update --force
cd /var/www/ghost/current
yarn add ghost-storage-adapter-s3 ghost-digitalocean
yarn upgrade
cp -R node_modules/ghost-storage-adapter-s3 core/server/adapters/storage/s3
cp -R node_modules/ghost-digitalocean core/server/adapters/storage/digitalocean
ghost restart

Use python with subprocess… Up was only example…

Turns out it’s possible to do an installation to /var/www/ghost/current that persists between updates.

I switched to GhoS3 which is more up-to-date. It has an installation guide that leaves a working installation in /var/www/ghost/current – of note is, it is necessary to use npm even though Ghost uses yarn for package management.