You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

73 lines
2.1 KiB

FROM debian:buster-slim
LABEL maintainer "Infer team"
# mkdir the man/man1 directory due to Debian bug #863199
RUN apt-get update && \
mkdir -p /usr/share/man/man1 && \
apt-get install --yes --no-install-recommends \
autoconf \
automake \
bzip2 \
cmake \
curl \
gcc \
git \
libc6-dev \
libgmp-dev \
libmpfr-dev \
libsqlite3-dev \
make \
openjdk-11-jdk-headless \
patch \
pkg-config \
python3.7 \
python3-distutils \
unzip \
zlib1g-dev && \
rm -rf /var/lib/apt/lists/*
# Install opam 2
RUN curl -sL https://github.com/ocaml/opam/releases/download/2.0.6/opam-2.0.6-x86_64-linux > /usr/bin/opam && \
chmod +x /usr/bin/opam
# Disable sandboxing
# Without this opam fails to compile OCaml for some reason. We don't need sandboxing inside a Docker container anyway.
RUN opam init --reinit --bare --disable-sandboxing
# Download the latest Infer master
RUN cd / && \
git clone https://github.com/facebook/infer/
# Build opam deps first, then infer. This way if any step fails we
# don't lose the significant amount of work done in the previous
# steps.
RUN cd /infer && \
INFER_OPAM_SWITCH=4.08.1 ./build-infer.sh --only-setup-opam --no-opam-lock java && \
opam clean
# Make sure clang is disabled
RUN eval $(opam env) && \
cd /infer && \
SKIP_SUBMODULES=true ./autogen.sh && \
./configure --disable-c-analyzers
# "Install" Infer. The tutorial assumes /infer-host is the working copy of infer so let's put it in the PATH too.
ENV PATH /infer-host/infer/bin:/infer/bin:$PATH
# build in non-optimized mode by default to speed up build times
[RFC][build] Use dune environments and profiles instead of contexts Summary: With profiles and `(env ...)` stanza it's possible to consolidate various ocamlc/ocamlopt/etc setups in a single place. Where previously we needed to append `dune.common` to every dune file and specify `flags` and `ocamlopt_flags` now the flags are specified in `env` and applied accross the board. This allows to 1. simplify build definitions, 2. avoid the need to generate dune files, 3. use plain sexps instead of OCaml and JBuilder plugin in build files. (I'll try to address 2 and 3 in the followup patches). Existing `make` targets should continue working as before. Also, we can use dune CLI like so: ``` infer/src$ dune printenv --profile opt # <- very useful for introspection infer/src$ dune build check infer/src$ dune build check --profile test infer/src$ dune build infer.exe --profile dev infer/src$ dune build infer.exe --profile opt ``` Also, with just 1 context something like `dune runtest` will run unit tests only once instead of N times, where N is the number of contexts. Now, there's one difference compared to the previous setup with contexts: - Previously, each context had its own build folder, and building infer in opt context didn't invalidate any of the build artifacts in default context. Therefore, alternating between `make` and `make opt` had low overhead at the expense of having N copies of all build artifacts (1 for every context). - Now, there's just 1 build folder and switching between profiles does invalidate some artifacts (but not all) and rebuild takes a bit more time. So, if you're alternating like crazy between profiles your experience may get worse (but not necessarily, more on that below). If you want to trigger an opt build occasionally, you shouldn't notice much difference. For those who are concerned about slower build times when alternating between different build profiles, there's a solution: [dune cache](https://dune.readthedocs.io/en/stable/caching.html). You can enable it by creating a file `~/.config/dune/config` with the following contents: ``` (lang dune 2.0) (cache enabled) ``` With cache enabled switching between different build profiles (but also branches and commits) has ~0 overhead. Dune cache works fine on Linux, but unfortunately there are [certain problems with MacOS](https://github.com/ocaml/dune/issues/3233) (hopefully, those will be fixed soon and then there will be no downsides to using profiles compared to contexts for our case). Reviewed By: jvillard Differential Revision: D20247864 fbshipit-source-id: 5f8afa0db
5 years ago
ENV BUILD_MODE=dev
# prevent exiting by compulsively hitting Control-D
ENV IGNOREEOF=9
# should be moved earlier
ENV INFER_OPAM_SWITCH=4.08.1
# export `opam env`
ENV OPAM_SWITCH_PREFIX=/root/.opam/4.08.1
ENV CAML_LD_LIBRARY_PATH=/root/.opam/4.08.1/lib/stublibs:/root/.opam/4.08.1/lib/ocaml/stublibs:/root/.opam/4.08.1/lib/ocaml
ENV OCAML_TOPLEVEL_PATH=/root/.opam/4.08.1/lib/toplevel
ENV MANPATH=$MANPATH:/root/.opam/4.08.1/man
ENV PATH=/root/.opam/4.08.1/bin:$PATH