catala/Dockerfile
Louis Gesbert 446481182f CI: update base build image
We need the new dates_calc and sedlex

Debug notes:
We need the latest ocamlpro/ocaml image (2024-05-26) to get the release of
dates_calc. Unfortunately, it breaks: `pip install gmpy2` could not find
pre-built binaries, so it would "transparently" try to recompile and then
complain about obscure system packages missing (mp libraries). Indeed the newest
image picked up the newer Alpine release (3.20), which is based on a newer musl
release (and apparently that's a problem !?).

Hopefully the proper python dependencies will become available at some point ?
2024-06-26 12:37:57 +02:00

55 lines
1.7 KiB
Docker

#
# STAGE 1: setup an opam switch with all dependencies installed
#
# (only depends on the opam files)
FROM ocamlpro/ocaml:4.14-2024-05-26 AS dev-build-context
# Image from https://hub.docker.com/r/ocamlpro/ocaml
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
# 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 && \
opam --cli=2.1 install . --with-test --with-doc --depext-only && \
opam --cli=2.1 install . --with-test --with-doc --deps-only && \
opam clean
# 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)
#
# STAGE 2: get the whole repo and build
#
FROM dev-build-context
# 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
# Get the full repo
ADD --chown=ocaml:ocaml . .
# OCaml backtraces may be useful on failure
ENV OCAMLRUNPARAM=b
# Make sure warnings are treated as errors (variable used in Makefile, profile
# defined in ./dune)
ENV DUNE_PROFILE=check
ARG CATALA_VERSION
# Check the build
RUN opam exec -- make build js_build
# Install to prefix
RUN opam exec -- make install && opam clean