how to use npmauthenticate step within azure dev-ops pipeline and not invalidate docker cache

Discussão em 'Angular' iniciado por user27873934, Outubro 19, 2024.

  1. user27873934

    user27873934 Guest

    I'm building a dockerized angular project using CICD from azure-devops. In my pipeline, I have:


    • dependencies that are installed from npm and some that are via artifact feeds within azure.


    • I have added the required .npmrc file at the root of my project and this all works ok.

    Within my pipeline, I'm using the npmAuthenticate step to grant authenticated access to the private registry. This step in turn appends a generated access token within .npmrc file.

    - task: npmAuthenticate@0
    inputs:
    workingFile: $(System.DefaultWorkingDirectory)/.npmrc
    feed: 'xxx-xx-xxx'


    As the whole build process is within docker, when it comes to copying over the .npmrc file, this is invalidating the docker cache, as the file has changes within it.

    FROM docker.io/node:lts-alpine AS builder

    WORKDIR /app

    COPY package*.json ./
    COPY .npmrc .npmrc //cache invalidates from this point

    RUN npm install
    COPY . ./

    RUN npm run build:project-x


    Is there anyway to achieve authenticated access with the .npmrc file without invalidating the cache. I want my future builds to get quicker and utilise cache node_modules.

    Continue reading...

Compartilhe esta Página