Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@ilguzin
Created May 29, 2019 07:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ilguzin/1ccfa6884608ab73c3343814c205a62f to your computer and use it in GitHub Desktop.
Save ilguzin/1ccfa6884608ab73c3343814c205a62f to your computer and use it in GitHub Desktop.
Use GitHub as your private NPM registry within your Dockerfile
FROM ...
ARG GITHUB_TOKEN # GITHUB_TOKEN is only defined for build stage! https://help.github.com/en/articles/creating-a-personal-access-token-for-the-command-line
RUN apk add git # This might contain more system packages depending on what is about to be installed by NPM
RUN git config --global url."https://${GITHUB_TOKEN}:x-oauth-basic@github.com".insteadOf ssh://git@github.com # Force NPM to use https://${GITHUB_TOKEN}:x-oauth-basic@github.com/<user name>/<repository>.git for modules installed from GitHub
COPY package.json /package.json
RUN npm ci
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment