[docker] update Dockerfiles

Summary:
Latest version was 0.14.0.
- re-use the new version in docker/master/Dockerfile for the most part,
  small change to download only the packages needed for running (instead
  of compiling) and to download the binary release instead of the
  source
- Update to Debian testing to be able to run the distributed binaries
  directly.
- remove "run.sh" script: the binaries have no examples to run infer on,
  so there's little value in executing the resulting docker image as-is.
  Instead, add instructions to mount local directories with a default to
  the source examples.
- make master-java the same as master/ except Java-only

Reviewed By: skcho

Differential Revision: D30157282

fbshipit-source-id: 54eaff40f
master
Jules Villard 3 years ago committed by Facebook GitHub Bot
parent b6278dfd7d
commit e4c65eb2a1

@ -1,47 +0,0 @@
FROM debian:stretch-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 \
cmake \
curl \
git \
libc6-dev \
libsqlite3-dev \
opam \
openjdk-8-jdk-headless \
pkg-config \
python2.7 \
zlib1g-dev && \
rm -rf /var/lib/apt/lists/*
# Download the latest Infer release
RUN INFER_VERSION=v0.14.0; \
cd /opt && \
curl -sL \
https://github.com/facebook/infer/releases/download/${INFER_VERSION}/infer-linux64-${INFER_VERSION}.tar.xz | \
tar xJ && \
rm -f /infer && \
ln -s ${PWD}/infer-linux64-$INFER_VERSION /infer
# Compile Infer
RUN OCAML_VERSION=4.06.1+flambda; \
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}
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,53 +0,0 @@
#!/bin/sh
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
EXEC_NAME="$0"
show_usage() {
echo "Usage: $EXEC_NAME [-h]"
echo ""
echo "Build and run the docker image. See infer/docker/README.md for more"
echo "information."
echo ""
echo "Options:"
echo " -h, --help Show this message and exit"
}
while [ -n "$1" ]; do
arg="$1"
case $arg in
"-h" | "--help" )
show_usage;
exit 0;
;;
*)
echo "unknown argument $1"
show_usage;
exit 1;
;;
esac
done
if ! docker --version > /dev/null; then
echo "docker install not working"
exit 1
fi
if [ ! -f Dockerfile ]; then
echo "Dockerfile not found. Are you in the right directory?"
echo "Please see infer/docker/README.md for more information."
exit 1
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,0 +1,27 @@
FROM debian:bullseye-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 \
curl \
libc6-dev \
openjdk-11-jdk-headless \
sqlite3 \
xz-utils \
zlib1g-dev && \
rm -rf /var/lib/apt/lists/*
# Download the Infer release
RUN INFER_VERSION=v1.1.0; \
cd /opt && \
curl -sL \
https://github.com/facebook/infer/releases/download/${INFER_VERSION}/infer-linux64-${INFER_VERSION}.tar.xz | \
tar xJ && \
rm -f /infer && \
ln -s ${PWD}/infer-linux64-$INFER_VERSION /infer
# Install infer
ENV PATH /infer/bin:${PATH}

@ -21,15 +21,17 @@ This docker file will use the latest
Infer.
1. Get docker running, e.g. using Docker Quickstart Terminal.
2. cd to the directory `docker/`,
3. Build Infer in docker container and try on an example:
2. go to the version of your choice, e.g. `cd docker/1.1.0/`
3. Build or install Infer in the Docker container and try on an example:
```sh
# Build Infer; 20min or so; to be executed from docker/ in the Infer repo
./run.sh
cd docker/1.1.0/
docker build -t infer .
# mount the local examples directory inside the image
# you can mount your project directory here instead
docker run -it infer -v $PWD/../../examples:/infer-examples /bin/bash
# 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
# "root@5c3b9af90d59:/# "
cd /infer-examples/
infer -- clang -c hello.c
```

@ -1,4 +1,4 @@
FROM debian:buster-slim
FROM debian:bullseye-slim AS compilator
LABEL maintainer "Infer team"
@ -11,6 +11,7 @@ RUN apt-get update && \
bzip2 \
cmake \
curl \
g++ \
gcc \
git \
libc6-dev \
@ -18,22 +19,21 @@ RUN apt-get update && \
libmpfr-dev \
libsqlite3-dev \
make \
opam \
openjdk-11-jdk-headless \
patch \
patchelf \
pkg-config \
python3.7 \
python3 \
python3-distutils \
unzip \
xz-utils \
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
RUN opam init --reinit --bare --disable-sandboxing --yes --auto-setup
# Download the latest Infer master
RUN cd / && \
@ -42,31 +42,28 @@ RUN cd / && \
# 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
RUN cd /infer && ./build-infer.sh java --only-setup-opam
RUN cd /infer && ./build-infer.sh java
# Make sure clang is disabled
RUN eval $(opam env) && \
cd /infer && \
SKIP_SUBMODULES=true ./autogen.sh && \
./configure --disable-c-analyzers
# Generate a release
RUN cd /infer && \
make install-with-libs \
BUILD_MODE=opt \
PATCHELF=patchelf \
DESTDIR="/infer-release" \
libdir_relative_to_bindir="../lib"
# "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
FROM debian:buster-slim AS executor
# build in non-optimized mode by default to speed up build times
ENV BUILD_MODE=dev
RUN apt-get update && apt-get install --yes --no-install-recommends sqlite3
# prevent exiting by compulsively hitting Control-D
ENV IGNOREEOF=9
# Get the infer release
COPY --from=compilator /infer-release/usr/local /infer
# should be moved earlier
ENV INFER_OPAM_SWITCH=4.08.1
# Install infer
ENV PATH /infer/bin:${PATH}
# 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
# if called with /infer-host mounted then copy infer there
RUN if test -d /infer-host; then \
cp -av /infer/. /infer-host; \
fi

@ -1,4 +1,4 @@
FROM debian:buster-slim AS compilator
FROM debian:bullseye-slim AS compilator
LABEL maintainer "Infer team"
@ -20,28 +20,25 @@ RUN apt-get update && \
libmpfr-dev \
libsqlite3-dev \
make \
opam \
openjdk-11-jdk-headless \
patch \
patchelf \
pkg-config \
python3.7 \
python3 \
python3-distutils \
unzip \
xz-utils \
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 --yes --auto-setup
# Download the latest Infer master
RUN cd / && \
git clone --depth 1 --recurse-submodules https://github.com/facebook/infer/
git clone --depth 1 https://github.com/facebook/infer/
# Build opam deps first, then clang, then infer. This way if any step
# fails we don't lose the significant amount of work done in the
@ -68,7 +65,7 @@ RUN apt-get update && apt-get install --yes --no-install-recommends sqlite3
# Get the infer release
COPY --from=compilator /infer-release/usr/local /infer
# Installl infer
# Install infer
ENV PATH /infer/bin:${PATH}
# if called with /infer-host mounted then copy infer there

Loading…
Cancel
Save