forked from
anil.recoil.org/monopam-myspace
My aggregated monorepo of OCaml code, automaintained
1FROM ocaml/opam:debian-ocaml-5.2 AS build
2
3# System dependencies
4RUN sudo apt-get update && sudo apt-get install -y \
5 autoconf \
6 pkg-config \
7 libgmp-dev \
8 libev-dev \
9 libffi-dev \
10 libssl-dev \
11 python3 \
12 jq \
13 && sudo rm -rf /var/lib/apt/lists/*
14
15# Set up oxcaml switch with the ox opam repo
16RUN opam update --all \
17 && opam switch create 5.2.0+ox \
18 --repos ox=git+https://github.com/oxcaml/opam-repository.git,alpha=git+https://github.com/kit-ty-kate/opam-alpha-repository.git,default \
19 && eval $(opam env --switch 5.2.0+ox)
20
21# Copy opam file first for dependency caching
22WORKDIR /home/opam/mono
23COPY --chown=opam:opam root.opam .
24RUN opam install --switch 5.2.0+ox --deps-only -y ./root.opam
25
26# Copy the full monorepo source
27COPY --chown=opam:opam . .
28
29# Build and install plugins, then build the site (without universes)
30RUN eval $(opam env --switch 5.2.0+ox) \
31 && dune build @install \
32 && dune install 2>/dev/null \
33 && dune build @site \
34 && dune build @doc
35
36# Assemble the site into _site/
37RUN mkdir -p _site \
38 && cp -rf _build/default/site/_html/* _site/ \
39 && cp -rf _build/default/_doc/_html/reference/* _site/reference/ \
40 && mkdir -p _site/odoc.support/ \
41 && cp -rf _build/default/_doc/_html/odoc.support/* _site/odoc.support/
42
43# Universe building (jtw is built from source in js_top_worker/)
44RUN eval $(opam env --switch 5.2.0+ox) \
45 && jtw opam astring base brr note mime_printer fpath rresult \
46 opam-format bos odoc.model tyxml yojson uri jsonm \
47 js_top_worker-widget-leaflet \
48 tessera-geotessera-jsoo tessera-viz-jsoo \
49 onnxrt -o _site/_opam
50
51# Deploy onnxrt assets
52RUN if [ -f onnxrt/example/sentiment/model_quantized.onnx ]; then \
53 cp onnxrt/example/sentiment/vocab.txt _site/_opam/vocab.txt \
54 && cp onnxrt/example/sentiment/model_quantized.onnx _site/_opam/model_quantized.onnx; \
55 fi \
56 && cp onnxrt/example/add.onnx _site/_opam/add.onnx
57
58# Lightweight final image with just the built site
59FROM nginx:alpine
60COPY --from=build /home/opam/mono/_site /usr/share/nginx/html
61EXPOSE 80