[英]Can I remove the build dependencies installed when building NodeJS from Source (such as g++, gcc, libstdc++6, etc )?
I built NodeJS from source on an ubuntu-slim image.我在 ubuntu-slim 图像上从源代码构建了 NodeJS。 When you do this it requires a lot of package installs in the process, such as (for example. below is Node16 dependencies)
当你这样做时,它需要在过程中安装大量 package,例如(例如。下面是 Node16 依赖项)
&& apt-get install --yes \
libstdc++6 \
...
...
&& apt-get install --yes \
binutils-gold \
g++ \
gcc \
gnupg \
libgcc-7-dev \
linux-headers-generic \
make \
python3 \
Once I have completed installing everything and configuring it, can I simply remove these build dependencies?完成所有内容的安装和配置后,我可以简单地删除这些构建依赖项吗? The image has grown extensively and I need to try to clean as much fat as possible.
图像已经广泛增长,我需要尝试尽可能多地清洁脂肪。 Of course, I still want NodeJS to run my node apps.
当然,我仍然希望 NodeJS 运行我的节点应用程序。
The same kind of process happens for NodeJS 14, and I am guessing NodeJS 18.. Can we remove these build dependencies once the NodeJS is built? NodeJS 14 也发生了同样的过程,我猜 NodeJS 18 .. 一旦构建了 NodeJS,我们可以删除这些构建依赖项吗?
After completing my building of Node14, I have found that:完成 Node14 的构建后,我发现:
npm install
ed- for example node-sass) - these are not common, so most uses of Node do not require this.npm install
时,本机节点软件包需要针对操作系统进行二进制编译 - 例如 node-sass) - 这些并不常见,所以大多数使用Node 不需要这个。apk-get
packages that were installed is as simple as using apk-get purge
.apk-get
软件包就像使用apk-get purge
一样简单。 The example below (building node inside a Dockerfile using shell script) gives some specifics. echo "Building from source" \
&& NODE_BUILD_PACKAGES="binutils-gold g++ gcc libgcc-7-dev linux-headers-generic make python3" \
&& apt-get install --yes ${NODE_BUILD_PACKAGES} \
...
...
[code to build node]
...
&& apt-get purge --yes ${NODE_BUILD_PACKAGES} \
&& apt-get clean \
&& apt-get autoremove --yes \
I used those three commands to clear out the build machine after building Node from source.在从源代码构建 Node 后,我使用这三个命令来清除构建机器。 For clarity, here is what each of those commands does:
为清楚起见,以下是每个命令的作用:
apt-get purge
removes the packages that I installed so that I could build Node.apt-get purge
删除了我安装的包,以便我可以构建 Node.js。apt-get clean
clears the local repository of retrieved package files that are left in /var/cache.apt-get clean
清除保留在 /var/cache 中的检索到的 package 文件的本地存储库。apt-get autoremove
removes packages that were automatically installed because some other package required them.apt-get autoremove
删除自动安装的软件包,因为其他一些 package 需要它们。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.