ghdl / docker

Scripts to build and use docker images including GHDL
40 stars 10 forks source link

Use middle stages in dockerfiles #5

Closed eine closed 5 years ago

eine commented 6 years ago

Now all the stages declared in the Dockerfiles are built as images. For example:

# [run] Fedora 28

FROM fedora:28 AS mcode

RUN dnf --nodocs -y install libgnat gcc \
 && dnf clean all --enablerepo=\*

#---

FROM mcode AS llvm

RUN dnf --nodocs -y install zlib-devel \
 && dnf clean all --enablerepo=\*

RUN dnf --nodocs -y install llvm-libs \
 && dnf clean all --enablerepo=\*

#---

FROM mcode AS gcc-8.1.0

RUN dnf --nodocs -y install zlib-devel \
 && dnf clean all --enablerepo=\*

RUN dnf --nodocs -y install libstdc++* libstdc++*.i686 \
 && dnf clean all --enablerepo=\*

This could be cleaner if the installation of zlib-devel was defined in a intermediate 'dummy' stage:

# [run] Fedora 28

FROM fedora:28 AS do-mcode

RUN dnf --nodocs -y install libgnat gcc \
 && dnf clean all --enablerepo=\*

#---

FROM mcode AS zlib

RUN dnf --nodocs -y install zlib-devel \
 && dnf clean all --enablerepo=\*

#---

FROM zlib AS do-llvm

RUN dnf --nodocs -y install llvm-libs \
 && dnf clean all --enablerepo=\*

#---

FROM zlib AS do-gcc-8.1.0
RUN dnf --nodocs -y install libstdc++* libstdc++*.i686 \
 && dnf clean all --enablerepo=\*