jshimko / meteor-launchpad

A base Docker image for Meteor applications.
https://hub.docker.com/r/jshimko/meteor-launchpad/
MIT License
276 stars 152 forks source link

Support of private npm modules #14

Closed vladholubiev closed 7 years ago

vladholubiev commented 7 years ago

Hey, looks like this is currently most active Meteor Docker image project!

But it misses support of private npm modules.

It's easy achievable with just two lines of code - https://docs.npmjs.com/private-modules/docker-and-private-modules

ARG NPM_TOKEN
RUN echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" >> .npmrc

Custom npm registry also can be adjusted, but I doubt this feature is wanted enough.

Also not sure if node creates empty .npmrc after installation, so maybe we should write token somewhere after install-node.sh, something to look at.

Anyway, thanks for putting your effort!

jshimko commented 7 years ago

@vladgolubev did you end up solving this on your own?

vladholubiev commented 7 years ago

@jshimko oh, it's been a while 😅

Yes, I was able to resolve this

jshimko commented 7 years ago

I'd be happy to add this support to the project. I'd like it to be as flexible as possible. What did you end up doing?

vladholubiev commented 7 years ago

I don't remember for what reason, it was long time ago, but I end-up using ulexus/meteor:v1.4-build as a base image and writing npm tokens as RUN commands in my Dockerfile.

For this project, I think it makes sense to put

echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ~/.npmrc in scripts/build-meteor.sh somewhere before line 27

and add ONBUILD ARG NPM_TOKEN somewhere in Dockerfile alongside other build arguments.

so it could be used as

docker build \
  --build-arg NPM_TOKEN="abcdef...." \
  -t myorg/myapp:latest .
jshimko commented 7 years ago

What happens if someone doesn't supply that arg? That npmrc is going to get created either way, no?

vladholubiev commented 7 years ago

Yes, it will be created, without token, and that's fine, npm can handle it. Public dependencies will be installed anyway

jshimko commented 7 years ago

Ok, great. Thanks for the details. I'll get it added in the next release.

dbuezas commented 7 years ago

this is not yet in, right?

jshimko commented 7 years ago

@dbuezas @vladgolubev Private npm module support has been added today in v2.2.0. Sorry for the wait!

https://github.com/jshimko/meteor-launchpad#installing-private-npm-packages

jshimko commented 7 years ago

For what it's worth, if you're logged in to npm already on your local machine, you can just do this to find your token...

cat ~/.npmrc 

Or to parse it out...

cat ~/.npmrc | cut -d "=" -f 2

Or on a Mac, to parse it out and add to your clipboard...

cat ~/.npmrc | cut -d "=" -f 2 | pbcopy