一次将所有依赖项安装一次,然后将它们用于所有下一个管道(每次不做NPM I)

发布于 2025-02-07 09:13:54 字数 252 浏览 2 评论 0原文

是否可以一次安装node_modules,并保存这些文件,而不是再次执行NPM CI,NPX playwright I等命令?

我正在剧作家进行测试自动化,并开始在Gitlab上面对问题,当我安装其组件时,据我所知,剧作家的一边存在一些连接问题(根据错误代码),并且完整的管道失败了。我想以某种方式解决它。

我也知道,还有另一种解决该问题的方法,也许从一开始就将Docker Image与已安装的剧作家和其他事情一起使用。

伙计们,你能建议我什么?

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 ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

请远离我 2025-02-14 09:13:54

一个空闲的方法可能是使用docker多阶段构建以完成此操作。将执行npm i的示例dockerfile附加,然后将静态文件复制到nginx容器。

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/

您的CI可能会使用

docker build -t myimagename .

您可以根据需要使用不同版本的Angular或NPM更改构建器阶段。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文