Skip to content

Commit

Permalink
[infer][PR] Dockerfile update
Browse files Browse the repository at this point in the history
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 facebook#597 (comment)):
```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 facebook#597

Differential Revision: D4906386

Pulled By: jvillard

fbshipit-source-id: 6bc09d2
  • Loading branch information
3flex authored and facebook-github-bot committed Apr 19, 2017
1 parent 1196728 commit 8a8fe9e
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 26 deletions.
59 changes: 33 additions & 26 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,51 +1,37 @@
# 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 \
m4 \
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 | \
Expand All @@ -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
1 change: 1 addition & 0 deletions docker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```
4 changes: 4 additions & 0 deletions docker/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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'

0 comments on commit 8a8fe9e

Please sign in to comment.