Home > other >  Install all dependencies on CI once and use them for all next pipelines (Not doing npm i every time)
Install all dependencies on CI once and use them for all next pipelines (Not doing npm i every time)

Time:06-15

is it possible to install node_modules with all dependencies one time and save these files, not doing npm ci, npx playwright i, etc commands again?

I'm doing test automation on playwright and started facing with problem on gitlab, when I'm installing its components, there are some connection problems(according to the error code) on playwright's side as I understand and full pipeline fails. I'd like to solve it somehow.

Also I know that there is another way to solve that problem, maybe use docker image with installed playwright and other things from the start.

What can you suggest me, guys ?

CodePudding user response:

An idle way could be to use docker multi stage builds to get this done. Attaching a sample dockerfile that does npm i then copy static files to nginx container.

Dockefile

ARG DistArtifact=teapot
FROM krravindra/angularbuilder:15 as builderstep
WORKDIR /app
ADD . /app
RUN npm i
RUN ng build

FROM nginx:1.17-alpine

COPY --from=builderstep /app/dist/$DistArtifact  /usr/share/nginx/html/

Your CI might use

docker build -t myimagename .

You can always change your builder stage with a different version of angular or npm as required.

  • Related