RocketChat / hubot-rocketchat

Rocket.Chat Hubot adapter
MIT License
581 stars 229 forks source link

Add ability to change scripts npm registry #237

Open jakawell opened 7 years ago

jakawell commented 7 years ago

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.

mechko commented 6 years ago

Had the same issue, solved it by mounting a single file volume via docker-compose.yml like so: ` volumes:

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

JSzaszvari commented 6 years ago

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