Dockerfile : add npm to an existing docker image

标签 docker jenkins npm

有了 Jenkins Docker 镜像,我想将完整的“npm”环境添加到该镜像中。因此,在构建 Dockerfile 后,我有一个包含 Jenkins 和“npm”环境的镜像。

目的是让 Jenkins 作业运行 shell 命令“npm”。所以“npm”应该位于 $PATH 上(在 Ubuntu 中)。

我已经有一个 Dockerfile,里面有很多东西,比如 Jenkins 和 Maven。

this post 中描述了节点的解决方案。重要的是,我可以做一些类似的事情吗?我应该将哪些文件夹复制到 Jenkins docker 镜像?

FROM node as nodejs

FROM jenkins/jenkins
// All kinds of other stuff goes here
COPY --from=nodejs /usr/local/bin/node /usr/local/bin/node ???

在 Jenkins 全局工具中自动安装“npm”不是我的首选解决方案。

最佳答案

使用多个 FROM 指令 is not a feature, it's a bug 。建议将其删除,并且您应该不惜一切代价避免使用它!

如果你的 jenkins 中需要 npm,只需将其安装在那里即可。无论如何,它都是基于 openjdk 镜像的。

FROM jenkins/jenkins

RUN apt-get install -y curl \
  && curl -sL https://deb.nodesource.com/setup_9.x | bash - \
  && apt-get install -y nodejs \
  && curl -L https://www.npmjs.com/install.sh | sh

关于Dockerfile : add npm to an existing docker image,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52412693/

相关文章:

git - docker 在包含 Dockerfile 的私有(private) git 存储库上构建?

git/jenkins TLS 问题

java - Maven 发布插件 - 如何修改发布项目的版本

visual-studio - ASP Core 发布前/发布后操作安装 Angular2 工具然后构建

javascript - 无法理解 Node.js walker

docker - 系统重启后 Mnesia 无法识别数据(no_exists 错误)

docker - 在 ubuntu 20.04 上部署 docker 容器到 swarm 时出现 br_netfilter 错误

laravel - 链接到容器时如何使用主机网络?

github - Jenkins 没有在第一次推送时建立新的分支

javascript - Balanced-JS 返回 404