hubot-rocketchat icon indicating copy to clipboard operation
hubot-rocketchat copied to clipboard

Add ability to change scripts npm registry

Open jakawell opened this issue 7 years ago • 2 comments

Our company has hubots that contain private functionality, so they're not on the main NPM registry. We're just now deploying our Rocket.Chat hubot adapter onto Docker (using a docker-compose file), and I've found that it's complicated to get the adapter to pull external scripts from our registry. I think it would be very easy to support an environment variable containing a registry URL and simply set the NPM registry as the first step in the Dockerfile command. I may have time to actually make this pull request, if everyone thinks it's worth adding. Is it worth my writing that fix?

Workaround

Here's the workaround I'm using right now, though I don't like it because I'm having to duplicate and manipulate the Dockerfile command, meaning if that command ever changes, I have to manually change my docker-compose: In the docker-compose file I override the command with this:

command: bash -c "npm set registry http://my.company.registry && \
node -e 'console.log(JSON.stringify(process.env.EXTERNAL_SCRIPTS.split(`,`)))' > external-scripts.json && \
npm install $$(node -e 'console.log(process.env.EXTERNAL_SCRIPTS.split(`,`).join(` `))') && \ 
bin/hubot -n $$BOT_NAME -a rocketchat"

Another workaround option of course is to fork the repository and create a new Dockerfile.

jakawell avatar Aug 23 '17 16:08 jakawell

Had the same issue, solved it by mounting a single file volume via docker-compose.yml like so: volumes: - ${PWD}/.npmrc:/home/hubot/.npmrc

The .npmrc contains URL and user / pass for accessing our scoped private NPM repo.

mechko avatar Mar 02 '18 08:03 mechko

Hi @jakawell

We're in the process of rebuilding this from the ground up and i've implemented your feature in the following PR - https://github.com/RocketChat/hubot-rocketchat/pull/289

There is still testing that needs to be done before this is pushed live, but you'll be able to do it by setting the NPM_REGISTRY environment var like so:

NPM_REGISTRY=https://my.company.registry

JSzaszvari avatar Jun 06 '18 15:06 JSzaszvari