问题原文
原帖链接 · sc911 · CC BY-SA 4.0
I'm using multi-stage builds to separate the build environment from the final docker image:
FROM ubuntu:bionic AS build
RUN apt-get update && apt-get install -y \
build-essential \
[...]
RUN wget https://someserver.com/somefile.tar.gz && \
tar xvzf somefile.tar.gz && \
./configure && \
make && make install && \
[missing part]
FROM ubuntu:bionic
COPY --from=build /tmp/fakeroot/ /
[...]
Is there an easy way to collect all files that where created/copied while make install was running?
Currently I'm using a combination of ldd and individual file copy to get them all:
cp /etc/xyz/* /tmp/fakeroot/xyz
cp --parents $(ldd /usr/sbin/nginx | grep -o '/.\+\.so[^ ]*' | sort | uniq) /tmp/fakeroot
But as make install already has the information of which file to copy to what directory I'm asking myself if there isn't any way to use this mechanism.
Thanks for any ideas!
已采纳解答
原帖链接 · sc911 · CC BY-SA 4.0
One way I found now is using checkinstall which replaces the make install step and tracks the installation to produce a package in the first stage. Then in the second stage I'm using dpkg to install this package.
So now I'm doing:
FROM ubuntu:bionic AS build
RUN [...]
./configure && \
make && \
checkinstall --install=no --default && \
cp XYZ-*.deb /XYZ.deb
FROM ubuntu:bionic
COPY --from=build /XYZ.deb /
RUN dpkg -i /XYZ.deb && \
rm /XYZ.deb && \
[...]
Any downsides of this approach?
摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。
