How to run a ruby script inside docker container?

I have an existing Discourse community with existing users. I added custom user fields that I need to update from an external source. I created and tested a .rb script in a local development environment. I’d now like to run that script against the production instance. Production environment is a self-hosted docker install at Digital Ocean.

I now need help with the following two (N00b) tasks:

  1. How do I copy the .rb file into the docker container from the host server?
  2. How do I execute the .rb file within the docker container?

I plan to take a backup of the production Discourse just before executing the script incase ‘bad things happen’.

Alternatively, am I better to use backup/restore to execute the script locally, then restore that to production? Just not wild about the downtime required for this approach.

Thanks for the help!

One time run? Or does it have to happen every rebuild? One time directions:

On your droplet:

cd /var/discourse
cp YOURSCRIPT shared/
./launcher enter app

And you are inside the container. Your script is now available as /shared/YOURSCRIPT

That sort of thing is good for one time DB tasks (where the results are stored in the DB) or stuff that runs a report but doesn’t need to be there after the next upgrade. For stuff that needs to be around always, you have to work with the app.yml file.

(And backups are always good.)


Exactly what I was looking for. This is just a one-time deal. Thank you for the quick reply!