From f2d80d1a40f5417957ad73a5ea21aecb45f24a82 Mon Sep 17 00:00:00 2001 From: Jules Villard Date: Thu, 22 Oct 2015 06:32:59 -0700 Subject: [PATCH] base image on release instead of git + doc + launch script Summary: public Add instructions how to use the docker image, a script to automatically build and run the docker container, and base the docker image on the latest release of infer instead of git, which saves compiling clang. Reviewed By: cristianoc Differential Revision: D2564909 fb-gh-sync-id: 5c8ea96 --- docker/Dockerfile | 69 +++++++++++++++++++++++++---------------------- docker/README.md | 31 +++++++++++++++++++++ docker/run.sh | 51 +++++++++++++++++++++++++++++++++++ 3 files changed, 119 insertions(+), 32 deletions(-) create mode 100644 docker/README.md create mode 100755 docker/run.sh diff --git a/docker/Dockerfile b/docker/Dockerfile index efd301947..f3f03f539 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -1,54 +1,59 @@ # Base image FROM heikomaass/android-sdk -# Author -MAINTAINER doctorq <542113578@qq.com> +MAINTAINER Infer +# Add build-tools-22 to the Android SDK +RUN ["/opt/sdk-tools/android-accept-licenses.sh", "android update sdk --filter \"build-tools-22.0.1\" --no-ui --force -a"] -# Install tools -RUN apt-get update; \ - apt-get upgrade; \ - apt-get install -y \ +# Debian config +RUN apt-get update && \ + apt-get install -y --no-install-recommends \ build-essential \ + curl \ git \ groff \ libgmp-dev \ libmpc-dev \ libmpfr-dev \ m4 \ + ocaml \ python-software-properties \ + rsync \ software-properties-common \ unzip \ zlib1g-dev +# Install a recent Gradle +RUN add-apt-repository ppa:cwchien/gradle +RUN apt-get update && \ + apt-get install gradle-2.5 + # Install OPAM -RUN add-apt-repository ppa:avsm/ppa -RUN apt-get update; \ - apt-get install -y \ - camlp4-extra \ - ocaml \ - ocaml-native-compilers \ - opam -RUN opam init --yes --comp=4.01.0 -RUN opam install -y extlib.1.5.4 atdgen.1.6.0 javalib.2.3.1 sawja.1.5.1 - -# Download Infer source code -RUN git clone https://github.com/facebook/infer.git - -# Install Facebook Clang Plugins and clang -RUN cd infer; git pull; \ - git submodule update --init; \ - facebook-clang-plugins/clang/setup.sh -RUN cd infer; eval $(opam config env); \ - git submodule update; \ - ./compile-fcp.sh +RUN curl -sL \ + https://github.com/ocaml/opam/releases/download/1.2.2/opam-1.2.2-x86_64-Linux \ + -o /usr/local/bin/opam && \ + chmod 755 /usr/local/bin/opam +RUN opam init -y --comp=4.01.0 && \ + opam install -y extlib.1.5.4 atdgen.1.6.0 javalib.2.3.1 sawja.1.5.1 + +# Download the latest Infer release +RUN INFER_VERSION=$(curl -s https://api.github.com/repos/facebook/infer/releases \ + | grep -e '^[ ]\+"tag_name"' \ + | head -1 \ + | cut -d '"' -f 4); \ + 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 cd /infer && \ + eval $(opam config env) && \ + make -C infer clang java # Install Infer -RUN cd infer; eval $(opam config env); \ - make -C infer clang java ENV INFER_HOME /infer/infer ENV PATH ${INFER_HOME}/bin:${PATH} - -# Install Gradle 2.5 -RUN add-apt-repository ppa:cwchien/gradle -RUN apt-get update; apt-get install gradle-2.5 diff --git a/docker/README.md b/docker/README.md new file mode 100644 index 000000000..aaa72b2c2 --- /dev/null +++ b/docker/README.md @@ -0,0 +1,31 @@ +# docker images for Infer + +This directory contains a docker file to install Infer within a +[docker](https://www.docker.com/) container. This can be used to +quickly try Infer or to deploy Infer. + + +## Pre-requisites + +To use this docker image, you will need a working docker +installation. See the instructions for +[Linux](http://docs.docker.com/linux/step_one/) or +[MacOSX](http://docs.docker.com/mac/step_one/) as appropriate. + + +## How to use + +This docker file will use the latest +[released](https://github.com/facebook/infer/releases) version of +Infer. Simply type "./run.sh" to get a shell inside the docker +container. It will have built and installed Infer. You can then try +out Infer on the introductory examples: + +```sh +# compiles Infer; this takes a few minutes +./run.sh +# you should now be inside the docker container with a shell prompt, e.g. +# "root@5c3b9af90d59:/# " +cd /infer/examples/android_hello/ +infer -- gradle build +``` diff --git a/docker/run.sh b/docker/run.sh new file mode 100755 index 000000000..9e8277d22 --- /dev/null +++ b/docker/run.sh @@ -0,0 +1,51 @@ +#!/bin/sh + +# Copyright (c) 2015 - present Facebook, Inc. +# All rights reserved. +# +# This source code is licensed under the BSD style license found in the +# LICENSE file in the root directory of this source tree. An additional grant +# of patent rights can be found in the PATENTS file in the same directory. + +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 . && \ +docker run -it $NAME /bin/bash