[infer][PR] Dockerfile update

Summary:
This cuts the resulting image from ~4.6GB to ~1.6GB.

Infer functionality is not sacrificed and the following commands run successfully without any extra user interaction (including Android example provided the user has accepted the Android SDK license which they'll be prompted to do when running the Docker image, see https://github.com/facebook/infer/pull/597#issuecomment-284864016):
```bash
cd /infer/examples && infer -- javac Hello.java
cd /infer/examples && infer -- gcc -c hello.c
cd /infer/examples && infer -- clang -c hello.c
cd /infer/examples/c_hello && infer -- make
cd /infer/examples/java_hello && infer -- javac Hello.java Pointers.java Resources.java
cd /infer/examples/android_hello && infer -- ./gradlew build
```

The OPAM installation is no longer retained. This may impact Infer developers if they're using the Docker images and require OPAM packages to be installed as part of their workflow.
Closes https://github.com/facebook/infer/pull/597

Differential Revision: D4906386

Pulled By: jvillard

fbshipit-source-id: 6bc09d2
master
Matthew Haughton 8 years ago committed by Facebook Github Bot
parent 119672894d
commit 8a8fe9eedd

@ -1,25 +1,19 @@
# Base image
FROM heikomaass/android-sdk
FROM buildpack-deps:xenial-curl
MAINTAINER Infer
# Add android-22 and build-tools-22 to the Android SDK
RUN ["/opt/sdk-tools/android-accept-licenses.sh", \
"android update sdk --filter \"android-22\" --no-ui --force --all"]
RUN ["/opt/sdk-tools/android-accept-licenses.sh", \
"android update sdk --filter \"build-tools-22.0.1\" --no-ui --force --all"]
# Debian config
RUN apt-get update && \
apt-get install -y --no-install-recommends \
aspcud \
autoconf \
curl \
automake \
gcc \
g++ \
git \
groff \
groff-base \
libc6-dev \
libffi-dev \
libgmp-dev \
libmpc-dev \
libmpfr-dev \
@ -27,25 +21,17 @@ RUN apt-get update && \
make \
ncurses-dev \
ocaml \
opam \
openjdk-8-jdk-headless \
pkg-config \
python-software-properties \
python2.7 \
rsync \
software-properties-common \
unzip \
zlib1g-dev
# Install OPAM
RUN VERSION=1.2.2; \
curl -sL \
https://github.com/ocaml/opam/releases/download/$VERSION/opam-$VERSION-x86_64-Linux \
-o /usr/local/bin/opam && \
chmod 755 /usr/local/bin/opam && \
((/usr/local/bin/opam --version | grep -q $VERSION) || \
(echo "failed to download opam from GitHub."; exit 1))
RUN opam init -y --comp=4.02.3
zlib1g-dev && \
rm -rf /var/lib/apt/lists/*
# Download the latest Infer release
RUN INFER_VERSION=v0.10.0; \
RUN INFER_VERSION=v0.11.0; \
cd /opt && \
curl -sL \
https://github.com/facebook/infer/releases/download/${INFER_VERSION}/infer-linux64-${INFER_VERSION}.tar.xz | \
@ -54,9 +40,30 @@ RUN INFER_VERSION=v0.10.0; \
ln -s ${PWD}/infer-linux64-$INFER_VERSION /infer
# Compile Infer
RUN cd /infer && \
./build-infer.sh
RUN OCAML_VERSION=4.04.0; \
opam init --compiler=$OCAML_VERSION -j $(getconf _NPROCESSORS_ONLN || echo 1) --yes && \
cd /infer && \
./build-infer.sh --opam-switch $OCAML_VERSION && \
rm -rf /root/.opam
# Install Infer
ENV INFER_HOME /infer/infer
ENV PATH ${INFER_HOME}/bin:${PATH}
# Install dependencies for Android sample
RUN apt-get update && \
apt-get install -y --no-install-recommends \
libc6-dev \
libc6-i386 \
lib32z1 \
lib32stdc++6 && \
rm -rf /var/lib/apt/lists/*
ENV ANDROID_HOME /opt/android-sdk-linux
WORKDIR $ANDROID_HOME
RUN curl -o sdk-tools-linux.zip \
https://dl.google.com/android/repository/sdk-tools-linux-3859397.zip && \
unzip sdk-tools-linux.zip && \
rm sdk-tools-linux.zip
ENV PATH ${ANDROID_HOME}/tools/bin:${PATH}
RUN echo "sdk.dir=${ANDROID_HOME}" > /infer/examples/android_hello/local.properties

@ -29,6 +29,7 @@ Infer.
./run.sh
# you should now be inside the docker container with a shell prompt, e.g.
# "root@5c3b9af90d59:/infer/examples# "
sdkmanager --licenses
cd android_hello/
infer -- ./gradlew build
```

@ -48,4 +48,8 @@ fi
NAME="infer"
docker build -t $NAME . && \
echo "*************************************************************" && \
echo "To build the Android example, you must accept the Android SDK" && \
echo "licenses by running 'sdkmanager --licenses' first." && \
echo "*************************************************************" && \
docker run -it $NAME /bin/bash -c 'cd /infer/examples/; exec /bin/bash'

Loading…
Cancel
Save