2023-06-19 19:02:31 +03:00
|
|
|
#
|
|
|
|
# STAGE 1: setup an opam switch with all dependencies installed
|
|
|
|
#
|
2022-07-18 18:08:46 +03:00
|
|
|
# (only depends on the opam files)
|
2024-01-15 13:20:31 +03:00
|
|
|
FROM ocamlpro/ocaml:4.14-2024-01-14 AS dev-build-context
|
2023-06-19 19:02:31 +03:00
|
|
|
# Image from https://hub.docker.com/r/ocamlpro/ocaml
|
2022-07-18 18:08:46 +03:00
|
|
|
|
|
|
|
RUN mkdir catala
|
|
|
|
WORKDIR catala
|
|
|
|
|
|
|
|
# Get only the opam files at this stage to allow caching
|
|
|
|
ADD --chown=ocaml:ocaml *.opam ./
|
|
|
|
|
|
|
|
# trigger the selection of catala dev tools in opam
|
|
|
|
ENV OPAMVAR_cataladevmode=1
|
|
|
|
ENV OPAMVAR_catalaz3mode=1
|
|
|
|
|
|
|
|
# Get a switch with all the dependencies installed
|
2023-06-19 19:02:31 +03:00
|
|
|
# DON'T run 'opam update' here. Instead use a newer parent Docker image
|
|
|
|
# (update the 'FROM' line above)
|
|
|
|
RUN opam --cli=2.1 switch create catala ocaml-system && \
|
2022-07-18 18:08:46 +03:00
|
|
|
opam --cli=2.1 install . --with-test --with-doc --depext-only && \
|
|
|
|
opam --cli=2.1 install . --with-test --with-doc --deps-only && \
|
|
|
|
opam clean
|
2023-06-19 19:02:31 +03:00
|
|
|
# Note: just `opam switch create . --deps-only --with-test --with-doc && opam clean`
|
|
|
|
# should be enough once opam 2.2 is released (see opam#5185)
|
|
|
|
|
|
|
|
#
|
2024-01-16 19:13:29 +03:00
|
|
|
# STAGE 2: get the whole repo and build
|
2023-06-19 19:02:31 +03:00
|
|
|
#
|
2022-08-01 20:56:04 +03:00
|
|
|
FROM dev-build-context
|
2022-07-18 18:08:46 +03:00
|
|
|
|
2024-01-16 19:13:29 +03:00
|
|
|
# Prepare extra local dependencies (doing this first allows caching)
|
|
|
|
ADD --chown=ocaml:ocaml runtimes/python/pyproject.toml runtimes/python/pyproject.toml
|
|
|
|
ADD --chown=ocaml:ocaml Makefile .
|
|
|
|
ADD --chown=ocaml:ocaml syntax_highlighting syntax_highlighting
|
|
|
|
RUN opam exec -- make dependencies-python pygments
|
|
|
|
|
2022-07-18 18:08:46 +03:00
|
|
|
# Get the full repo
|
|
|
|
ADD --chown=ocaml:ocaml . .
|
|
|
|
|
|
|
|
# OCaml backtraces may be useful on failure
|
|
|
|
ENV OCAMLRUNPARAM=b
|
2023-02-28 19:26:49 +03:00
|
|
|
# Make sure warnings are treated as errors (variable used in Makefile, profile
|
|
|
|
# defined in ./dune)
|
|
|
|
ENV DUNE_PROFILE=check
|
2022-07-18 18:08:46 +03:00
|
|
|
|
2024-01-22 16:57:43 +03:00
|
|
|
ARG CATALA_VERSION
|
|
|
|
|
2022-07-18 18:08:46 +03:00
|
|
|
# Check the build
|
2024-01-16 19:13:29 +03:00
|
|
|
RUN opam exec -- make build js_build
|
2022-07-18 18:08:46 +03:00
|
|
|
|
2024-01-16 19:13:29 +03:00
|
|
|
# Install to prefix
|
2024-01-22 15:50:31 +03:00
|
|
|
RUN opam exec -- make install && opam clean
|