[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
master
Jesús Marín 6 years ago committed by Facebook Github Bot
parent 79b0b8172d
commit bef697c50e

@ -1,4 +1,4 @@
FROM debian:stretch-slim FROM debian:stretch-slim AS compilator
LABEL maintainer "Infer team" LABEL maintainer "Infer team"
@ -22,6 +22,7 @@ RUN apt-get update && \
make \ make \
openjdk-8-jdk-headless \ openjdk-8-jdk-headless \
patch \ patch \
patchelf \
pkg-config \ pkg-config \
python2.7 \ python2.7 \
unzip \ 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 # Disable sandboxing
# Without this opam fails to compile OCaml for some reason. We don't need sandboxing inside a Docker container anyway. # 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 # Download the latest Infer master
RUN cd / && \ RUN cd / && \
@ -54,20 +55,27 @@ RUN cd /infer && \
./configure && \ ./configure && \
./facebook-clang-plugins/clang/setup.sh ./facebook-clang-plugins/clang/setup.sh
# Hackish for now: pull to get the latest version # Generate a release
RUN cd /infer && git pull 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 # if called with /infer-host mounted then copy infer there
RUN if test -d /infer-host; then \ RUN if test -d /infer-host; then \
cp -av /infer/. /infer-host; \ cp -av /infer/. /infer-host; \
fi 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

Loading…
Cancel
Save