简体   繁体   English

npm install in bitbucket pipeline vs docker

[英]npm install in bitbucket pipeline vs docker

My company is using bitbucket-pipeline alongside with docker to build an image of the application before deploying it.我的公司正在使用 bitbucket-pipeline 和 docker 在部署之前构建应用程序的映像。

When I'm reading into the docker file, I can see these lines:当我读入 docker 文件时,我可以看到这些行:

(ignored a bunch of lines)
RUN yarn install
RUN yarn run my-script
COPY . .

and in pipeline, I see this script在管道中,我看到了这个脚本

docker build .

My question is, is there any reason why I should put RUN yarn install and RUN yarn run my-script into docker and not in pipeline?我的问题是,有什么理由我应该将RUN yarn installRUN yarn run my-script放入 docker 而不是管道中?

My reasons behind putting it in pipeline is so you can utilise cache from bitbucket pipeline, as well as lower the size of the docker image (I understand that few layers means smaller image size).我将其放入管道的原因是您可以利用 bitbucket 管道中的缓存,以及降低 docker 映像的大小(我知道层数越少意味着映像大小越小)。

I have seen both setup in various projects.我已经在各种项目中看到了这两种设置。 yarn install within the docker environment would still be my preferred choice because of the separation of domain it provide. docker 环境中的 yarn install 仍然是我的首选,因为它提供了域分离。 Imaging having a team of many people - setting up YARN install within docker developers don't have to worry about npm environment on their own machines.想象有一个多人团队 - 在 docker 开发人员中设置 YARN 安装不必担心自己机器上的 npm 环境。 Ideally if you are utilising docker then local machine should not have anything but docker.理想情况下,如果您使用的是 docker,那么本地机器应该只有 docker。 Same goes for PIPELINE - if you ever decide to move away from bitbucket-pipeline - having everything contained within the docker environment you can just pack up and go. PIPELINE 也是如此——如果你决定离开 bitbucket-pipeline——将所有东西都包含在 docker 环境中,你可以打包并离开。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM