Skip to content

Instantly share code, notes, and snippets.

@ilguzin
Created May 29, 2019 07:59
Show Gist options
  • 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}:[email protected]".insteadOf ssh://[email protected] # Force NPM to use https://${GITHUB_TOKEN}:[email protected]/<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