Set of artifacts that needs to be copied for Docker multistage builds with yum

Viewed 473

I'm trying to build a multistage docker image from centos

FROM centos as python-base

RUN yum install -y wget \
tar \
make \
gcc \
gcc-c++ \
zlib \
zlib-devel \
libffi-devel \
openssl-devel \
&& yum clean all

WORKDIR /usr/src/

RUN wget https://www.python.org/ftp/python/3.7.0/Python-3.7.0.tgz

RUN tar xzf Python-3.7.0.tgz

WORKDIR /usr/src/Python-3.7.0

RUN ./configure --enable-optimizations

RUN make altinstall

RUN python3.7 -V

#=====================================================================================

FROM centos:cs as python37

COPY --from=python-base /usr/local/lib/python3.7 /usr/local/lib/python3.7
COPY --from=python-base /usr/local/bin/pip3.7 /usr/local/bin/pip3.7
COPY --from=python-base /usr/local/bin/python3.7 /usr/local/bin/python3.7

RUN ln -s /usr/local/bin/pip3.7 /usr/local/bin/pip
RUN ln -s /usr/local/bin/python3.7 /usr/local/bin/python

As show above, I've build python37 from the python-base stage. Here, I've copied the required artifacts from python-base to python37 stage.

FROM centos as httpd-base

RUN yum -y groupinstall "Development tools"\
httpd-2.4.6-88.el7.centos.x86_64 \
&& yum clean all

So my question is, what is the set of artifacts that needs to be copied from httpd-base stage to build an image that has httpd and not all the developments tools that is required only during installation.

Any best practices in this regard is also appreciated. Thanks in advance.

0 Answers
Related