From bef697c50eef547f6a5a9fcf92b69cf20f62a165 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs=20Mar=C3=ADn?= Date: Wed, 22 May 2019 05:21:43 -0700 Subject: [PATCH] [infer][PR] Improvements in docker container generation Summary: Using "opam init" in non interactive mode, in order to avoid compilation failures. Otherwise, It will wait for user input until a timeout, that will cause the compilation process to fail due to an OPAM error. Also the Dockerfile has been modified in order to use [multistage builds](https://docs.docker.com/develop/develop-images/multistage-build/), obtaining a cleaner Docker image. Pull Request resolved: https://github.com/facebook/infer/pull/1102 Reviewed By: jvillard Differential Revision: D15430898 Pulled By: mbouaziz fbshipit-source-id: 0718163bb --- docker/master/Dockerfile | 36 ++++++++++++++++++++++-------------- 1 file changed, 22 insertions(+), 14 deletions(-) diff --git a/docker/master/Dockerfile b/docker/master/Dockerfile index bc8c93134..a1f67e406 100644 --- a/docker/master/Dockerfile +++ b/docker/master/Dockerfile @@ -1,4 +1,4 @@ -FROM debian:stretch-slim +FROM debian:stretch-slim AS compilator LABEL maintainer "Infer team" @@ -22,6 +22,7 @@ RUN apt-get update && \ make \ openjdk-8-jdk-headless \ patch \ + patchelf \ pkg-config \ python2.7 \ unzip \ @@ -38,7 +39,7 @@ RUN curl -sL https://github.com/ocaml/opam/releases/download/2.0.3/opam-2.0.3-x8 # 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 +RUN opam init --reinit --bare --disable-sandboxing --yes --auto-setup # Download the latest Infer master RUN cd / && \ @@ -54,20 +55,27 @@ RUN cd /infer && \ ./configure && \ ./facebook-clang-plugins/clang/setup.sh -# Hackish for now: pull to get the latest version -RUN cd /infer && git pull +# Generate a release +RUN cd /infer && \ + make install-with-libs \ + BUILD_MODE=opt \ + PATCHELF=patchelf \ + DESTDIR="/infer-release" \ + libdir_relative_to_bindir="../lib" + +FROM debian:stretch-slim AS executor + +# Install python 2.7 since infer requires it to run +RUN apt-get update && apt-get install --yes --no-install-recommends \ + python2.7 + +# Get the infer release +COPY --from=compilator /infer-release/usr/local /infer + +# Installl infer +ENV PATH /infer/bin:${PATH} # if called with /infer-host mounted then copy infer there RUN if test -d /infer-host; then \ cp -av /infer/. /infer-host; \ fi - -# Install Infer -ENV INFER_HOME /infer/infer -ENV PATH ${INFER_HOME}/bin:${PATH} - -# build in non-optimized mode by default to speed up build times -ENV BUILD_MODE=default - -# prevent exiting by compulsively hitting Control-D -ENV IGNOREEOF=9