diff options
| author | Erik Martin-Dorel | 2018-12-20 16:07:41 +0100 |
|---|---|---|
| committer | Erik Martin-Dorel | 2018-12-21 12:17:07 +0100 |
| commit | 1c14614a2328d1854fd584d8d7ca54121faec0ee (patch) | |
| tree | 57b477883b1cb5f17f623f42aba2897a96b4557c /Dockerfile | |
| parent | 3b654a62d7938e674e99a6bfd3823016db067bee (diff) | |
Improve the mathcomp-dev Dockerfile (using Docker's multi-stage build)
* Install coq-mathcomp-character in only 1 switch (cf. the build-arg $compiler)
* Remove the other switch
* Base the final image on coqorg/base:bare (which has no OCaml compiler layers)
Diffstat (limited to 'Dockerfile')
| -rw-r--r-- | Dockerfile | 21 |
1 files changed, 14 insertions, 7 deletions
@@ -1,8 +1,5 @@ ARG coq_image="coqorg/coq:dev" -FROM ${coq_image} - -ENV MATHCOMP_VERSION="dev" -ENV MATHCOMP_PACKAGE="coq-mathcomp-character" +FROM ${coq_image} as builder WORKDIR /home/coq/mathcomp @@ -14,10 +11,12 @@ ARG compiler="base" RUN ["/bin/bash", "--login", "-c", "set -x \ && declare -A switch_table \ && switch_table=( [\"base\"]=\"${COMPILER}\" [\"edge\"]=\"${COMPILER_EDGE}\" ) \ - && compiler=\"${switch_table[${compiler}]}\" \ - && [ -n \"$compiler\" ] \ - && opam switch set ${compiler} \ + && opam_switch=\"${switch_table[${compiler}]}\" \ + && [ -n \"opam_switch\" ] \ + && opam switch set ${opam_switch} \ && eval $(opam env) \ + && unset \"switch_table[${compiler}]\" \ + && for sw in \"${switch_table[@]}\"; do if [ -n \"$sw\" ]; then opam switch remove -y \"${sw}\"; fi; done \ && opam repository add --all-switches --set-default coq-extra-dev https://coq.inria.fr/opam/extra-dev \ && opam repository add --all-switches --set-default coq-core-dev https://coq.inria.fr/opam/core-dev \ && opam update -y \ @@ -31,3 +30,11 @@ RUN ["/bin/bash", "--login", "-c", "set -x \ && opam pin add -n -k path coq-mathcomp-character . \ && opam install -y -v -j ${NJOBS} coq-mathcomp-character \ && opam clean -a -c -s --logs"] + +FROM coqorg/base:bare + +ENV MATHCOMP_VERSION="dev" +ENV MATHCOMP_PACKAGE="coq-mathcomp-character" + +COPY --from=builder --chown=coq:coq /home/coq/.opam /home/coq/.opam +COPY --from=builder --chown=coq:coq /home/coq/.profile /home/coq/.profile |
