3

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.

Keerthana Prabhakaran
  • 3,766
  • 1
  • 13
  • 23
  • though not related, but won't your yum break when you replace the python link. as yum requires py2.7 to work. – v_sukt Jan 03 '19 at 11:07
  • @v_sukt python2.7.5 is installed in the centos image that I use in dev. So I'd have both python2.7.5 and python3.7.0! – Keerthana Prabhakaran Jan 03 '19 at 12:06
  • Im having trouble understanding your terminology. What exactly do you mean when you say "artifacts"? Also, are the aforementioned docker files all their own separate file? – Jouster500 Jan 03 '19 at 17:37
  • @Jouster500, for example, while installing python, the artifacts would be the python and pip executable, and the lib folder. The src folders can be skipped while carring on to the next stage. – Keerthana Prabhakaran Jan 04 '19 at 06:22
  • So your question is asking what is the minimal required packages for an httpd packages? – Jouster500 Jan 04 '19 at 15:45
  • @Jouster500, not exactly. I want to know that set of files that can be copied for any package installed using yum to work fine. – Keerthana Prabhakaran Jan 06 '19 at 08:04
  • You can list files ("artifacts") of the package: rpm -ql . But you can't copy all files between systems. Especially dynamic linked binaries/libraries. They depend on glibc version. So if images centos:cs and centos have different glibc versions, then copied binaries may have a problem to start. – Jan Garaj Jan 07 '19 at 06:51

0 Answers0