Skip to content
This repository has been archived by the owner on Dec 13, 2018. It is now read-only.

Latest commit

 

History

History
28 lines (19 loc) · 1.3 KB

npm.md

File metadata and controls

28 lines (19 loc) · 1.3 KB

Working with GitHub repositories requiring private npm modules

In order to require private npm modules, you will need to export an npm access token environment variable in the ecs-conex build, and write that access token to an .npmrc file in your GitHub repository's Dockerfile.

  1. Your ecs-conex CloudFormation stack was provided with an npm access token in the parameter NPMAccessToken. This exposes your token to the GitHub repository you are watching.
  2. In your GitHub repository's Dockerfile, specify that you'd like to pass the npm access token at build-time, write this token to .npmrc prior to dependency installation:
# define build arguments
ARG NPMAccessToken

# create .npmrc file
RUN echo "//registry.npmjs.org/:_authToken=$NPMAccessToken" > ./.npmrc
ONBUILD COPY .npmrc ./

# install app dependencies. DO NOT change directories before doing so
RUN npm install

# Clean up
RUN rm -f ./.npmrc

Note that your Dockerfile must place the .npmrc file in the directory where you will npm install.

During local Docker builds, be sure to pass in the NPMAccessToken as part of the build arg: docker build --build-arg NPMAccessToken=ABCDEFGHIJKLMNOP -t your-repo ./

Checkout the NPM docs for more on Docker and private modules.