Skip to content

Using the library with Docker

LOCAL docker build using docker secrets

In your docker file, you will need to add the .npmrc-file to the docker environment in some way. This can be done by mounting it as a docker secret.

In the working dir for your client app, mount the secret file for .npmrc and run npm install:

# # Add token via .npmrc
RUN --mount=type=secret,id=npmrc,dst=/root/.npmrc \
npm install

The secret itself can be mounted by specifying it with the build command.

For windows:

Terminal window
docker build --secret id=npmrc,src="$env:USERPROFILE/.npmrc"

For Mac or Linux:

Terminal window
docker build --secret id=npmrc,src="~/.npmrc"

Alternately, if you use docker-compose, you can specify the secret in your YAML file:

services:
portal:
build:
context: .
dockerfile: ./src/YourDockerfilePath
secrets:
- npmrc
secrets:
npmrc:
file: ${NPMRC_FILE}

The .npmrc file needs to contain the grammar-web feed details, as well as a personal access token (PAT). The layout is given below (the top three lines will need substitutions by you):

//pkgs.dev.azure.com/teleplanglobe/_packaging/GrammarWeb/npm/registry/:username=YOUR_AZURE_DEVOPS_USERNAME
//pkgs.dev.azure.com/teleplanglobe/_packaging/GrammarWeb/npm/registry/:_password=BASE64_ENCODED_PAT
//pkgs.dev.azure.com/teleplanglobe/_packaging/GrammarWeb/npm/registry/:email=you@example.com
//pkgs.dev.azure.com/teleplanglobe/_packaging/GrammarWeb/npm/registry/:always-auth=true

Official instructions for aquiring the PAT, and setting up the file, can be found in Azure DevOps:

  1. Follow this link
  2. Click the npm option on the left

Discovered an error?

Or was something unclear?

Feel free to send us a ticket from the button in the top header of this page.