制作该Image的目的

由于Infer工具刚刚推出来,很多人想试用该工具,但是又苦于环境的配置略显复杂,最近有很多人找我解决关于环境配置的问题,这阻碍了Infer的推广。而Docker技术具有易移植的特性,将该工具的环境制作成Image,你只需下载在到本地就可以体验该新工具的特性,就可以对其做一个简单的了解。

注意:OC和iOS项目的分析是不支持的

Dockerfile

我并没有利用Dockerfile来制作该Image,但是我将我制作的Dockerfile贴出来,方便大家了解我的制作过程:

# Base image
FROM heikomaass/android-sdk# Author
MAINTAINER doctorq <542113578@qq.com># Upgrade apt-get tool
RUN apt-get update
RUN apt-get -y upgrade# Install tools
RUN apt-get install -y git m4 zlib1g-dev python-software-properties \build-essential libgmp-dev libmpfr-dev libmpc-dev unzip software-properties-common python-software-properties# Install opam
RUN add-apt-repository ppa:avsm/ppa
RUN apt-get update
RUN apt-get install -y ocaml ocaml-native-compilers camlp4-extra opam
RUN opam init --comp=4.01.0  # (answer 'y' to the question)
ENV CAML_LD_LIBRARY_PATH /root/.opam/4.01.0/lib/stublibs
ENV MANPATH :/root/.opam/4.01.0/man
ENV PERL5LIB /root/.opam/4.01.0/lib/perl5
ENV OCAML_TOPLEVEL_PATH /root/.opam/4.01.0/lib/toplevel
ENV OPAM_HOME /root/.opam/4.01.0/bin
ENV PATH ${PATH}:${CAML_LD_LIBRARY_PATH}:${MANPATH}:${PERL5LIB}:${OCAML_TOPLEVEL_PATH}:${OPAM_HOME}
#RUN opam update
RUN opam install sawja.1.5.1 atdgen.1.6.0 javalib.2.3.1 extlib.1.5.4# Download infer source code
RUN git clone https://github.com/facebook/infer.git# Install facebook-clang-plugin,clang
RUN cd infer;./update-fcp.sh;
RUN cd infer;apt-get install -y groff
RUN cd infer;../facebook-clang-plugin/clang/setup.sh;
RUN eval `opam config env`;cd infer;./compile-fcp.sh
RUN eval `opam config env`;cd infer;make -C infer
ENV INFER_HOME /infer/infer
ENV PATH ${PATH}:${INFER_HOME}/bin#Install gradle-2.5
RUN add-apt-repository ppa:cwchien/gradle
RUN apt-get update
#RUN apt-cache search gradle
RUN apt-get install gradle-2.5
CMD eval `opam config env`

(我会实际操作一次,等我有时间的时候)

上传

在经历了1个礼拜的上传失败后,公司的网络终于给力了,infer 的image终于上传Docker Hub成功.

成功信息


58deMacBook-Pro:~ wuxian$ docker push doctorq/infer
The push refers to a repository [doctorq/infer] (len: 1)
334f8536c724: Image already exists
79c86a401c9e: Image already exists
b08982ff2ae7: Image already exists
295452c2332e: Image already exists
6f7ac6b3c22e: Image successfully pushed
2f723dfaaf02: Image successfully pushed
4f8c30699e9d: Image successfully pushed
cd797a7e1a37: Image successfully pushed
3ebbcb595d4f: Image successfully pushed
2d901fe5706a: Image successfully pushed
2ab20d71784e: Image already exists
86f5a419baeb: Image successfully pushed
87936850fe94: Image already exists
6a34f2ecf1ae: Image already exists
896c84d68ec8: Image successfully pushed
f95fdfd19566: Image successfully pushed
68f48e28c14b: Image successfully pushed
918558524beb: Image successfully pushed
e81d2d3af07f: Image successfully pushed
569a964ec2cc: Image successfully pushed
1885bd64f8f7: Image successfully pushed
c00c3cf3b2b4: Image successfully pushed
d473f52c6131: Image successfully pushed
8d9b9414ed80: Image successfully pushed
76a68924d522: Image already exists
6be21d1e5d1e: Image already exists
020431a88ee9: Image successfully pushed
602e15acbcda: Image successfully pushed
cab7c4dcf81b: Image successfully pushed
Digest: sha256:ba58f6ad6d2725e2bc94bfc381217b2de7b477d4448eafd8366474aab873f609

成功截图

使用步骤

前提是你的docker环境已经配置完成

下载到本地

进入容器

docker run -it doctorq/infer /bin/bash

infer源码位置

root/infer

root@f71395f22159:/# cd root/infer
root@f71395f22159:~/infer# ls -l
total 56
-rw-r--r-- 1 root root  235 Jul 13 04:11 CONTRIBUTING.md
-rw-r--r-- 1 root root 1206 Jul 13 04:11 FILES.md
-rw-r--r-- 1 root root 3795 Jul 13 04:11 INSTALL.md
-rw-r--r-- 1 root root 1501 Jul 13 04:11 LICENSE
-rw-r--r-- 1 root root 1982 Jul 13 04:11 PATENTS
-rw-r--r-- 1 root root  429 Jul 13 04:11 README.md
-rwxr-xr-x 1 root root 1787 Jul 13 04:11 compile-fcp.sh
drwxr-xr-x 4 root root 4096 Jul 13 04:11 dependencies
drwxr-xr-x 6 root root 4096 Jul 16 07:39 examples
drwxr-xr-x 9 root root 4096 Jul 13 04:19 infer
-rw-r--r-- 1 root root  304 Jul 13 04:11 infer.install
-rw-r--r-- 1 root root  545 Jul 13 04:11 opam
drwxr-xr-x 2 root root 4096 Jul 13 04:11 scripts
-rwxr-xr-x 1 root root  739 Jul 13 04:11 update-fcp.sh

分析

我们以源码中的例子来分析,首先进入examples目录。

root@f71395f22159:~/infer# cd examples/
root@f71395f22159:~/infer/examples# ls -l
total 40
-rw-r--r-- 1 root root  396 Jul 16 07:39 Hello.class
-rw-r--r-- 1 root root   79 Jul 13 04:11 Hello.java
-rw-r--r-- 1 root root  182 Jul 13 04:11 Hello.m
-rw-r--r-- 1 root root 1221 Jul 13 04:11 README
drwxr-xr-x 7 root root 4096 Jul 13 09:16 android_hello
drwxr-xr-x 3 root root 4096 Jul 13 07:58 c_hello
-rw-r--r-- 1 root root   65 Jul 13 04:11 hello.c
-rw-r--r-- 1 root root 1240 Jul 13 07:58 hello.o
drwxr-xr-x 8 root root 4096 Jul 16 07:39 infer-out
drwxr-xr-x 6 root root 4096 Jul 13 08:00 ios_hello

Java文件

root@f71395f22159:~/infer/examples# infer -- javac Hello.java
Starting analysis (Infer version git-1356fd331f3db485be9ee38446a7389c9310d344)
Analysis done1 file analyzed/root/infer/examples/Hello.java:4: error: NULL_DEREFERENCEobject s last assigned on line 3 could be null and is dereferenced at line 4root@f71395f22159:~/infer/examples# 

Android项目

root@f71395f22159:~/infer/examples/android_hello# gradle clean
:app:cleanBUILD SUCCESSFULTotal time: 6.522 secsThis build could be faster, please consider using the Gradle Daemon: http://gradle.org/docs/2.5/userguide/gradle_daemon.html
root@f71395f22159:~/infer/examples/android_hello# infer -- gradle build
08:11:22.183 [ERROR] [org.gradle.api.Project] /root/infer/examples/android_hello/app/build/intermediates/exploded-aar/com.android.support/appcompat-v7/22.0.0/res/drawable-hdpi-v4/abc_spinner_mtrl_am_alpha.9.png: libpng warning: iCCP: Not recognizing known sRGB profile that has been edited
08:11:36.470 [ERROR] [org.gradle.api.Project] /root/infer/examples/android_hello/app/build/intermediates/exploded-aar/com.android.support/appcompat-v7/22.0.0/res/drawable-hdpi-v4/abc_spinner_mtrl_am_alpha.9.png: libpng warning: iCCP: Not recognizing known sRGB profile that has been edited
Starting analysis (Infer version git-1356fd331f3db485be9ee38446a7389c9310d344)
Analysis done5 files analyzed/root/infer/examples/android_hello/app/src/main/java/infer/inferandroidexample/MainActivity.java:20: error: NULL_DEREFERENCEobject s last assigned on line 19 could be null and is dereferenced at line 20/root/infer/examples/android_hello/app/src/main/java/infer/inferandroidexample/MainActivity.java:37: error: RESOURCE_LEAKresource acquired to fis by call to FileOutputStream(...) at line 34 is not released after line 37root@f71395f22159:~/infer/examples/android_hello#

C文件

root@f71395f22159:~/infer/examples# infer -- gcc -c hello.c
Starting analysis (Infer version git-1356fd331f3db485be9ee38446a7389c9310d344)
Analysis done1 file analyzedhello.c:5: error: NULL_DEREFERENCEpointer s last assigned on line 4 could be null and is dereferenced at line 5, column 3

C 项目


root@f71395f22159:~/infer/examples/c_hello# make clean
rm -rf example.o
root@f71395f22159:~/infer/examples/c_hello# infer -- make
cc -c example.c
Starting analysis (Infer version git-1356fd331f3db485be9ee38446a7389c9310d344)
Analysis done1 file analyzedexample.c:22: error: NULL_DEREFERENCEpointer max last assigned on line 21 could be null and is dereferenced at line 22, column 10example.c:36: error: NULL_DEREFERENCEpointer joe last assigned on line 35 could be null and is dereferenced by call to get_age() at line 36, column 10example.c:45: error: RESOURCE_LEAKresource acquired to fd by call to open() at line 41, column 12 is not released after line 45, column 5example.c:51: error: MEMORY_LEAKmemory dynamically allocated to p by call to malloc() at line 51, column 14 is not reachable after line 51, column 3example.c:57: error: MEMORY_LEAKmemory dynamically allocated to p by call to malloc() at line 56, column 14 is not reachable after line 57, column 3root@f71395f22159:~/infer/examples/c_hello#

Infer工具Docker image发布相关推荐

  1. 开发工具-Docker学习

    完整文章地址 Docker概述 Docker应用 部署环境复杂,非常费时费力 环境不能跨平台 docker可以把环境打包成镜像,直接运行即可 docker通过隔离机制,可以将服务器利用到极致 Dock ...

  2. docker镜像内容如何查看_如何快速打通 Docker 镜像发布流程?

    作者 | 菜菜 责编 | 郭芮 YY妹:菜菜哥,我看了一下Docker相关的内容,但是还是有点迷糊. 菜菜:还有哪不明白呢? YY妹:如果我想用Docker实现所谓的云原生,我的项目该怎么发布呢? 菜 ...

  3. 程序员修神之路--打通Docker镜像发布容器运行流程

    菜菜哥,我看了一下docker相关的内容,但是还是有点迷糊 还有哪不明白呢? 如果我想用docker实现所谓的云原生,我的项目该怎么发布呢? 这还是要详细介绍一下docker了 Docker 是一个开 ...

  4. 安装容器编排工具 Docker Compose

    安装容器编排工具 Docker Compose  curl -L https://get.daocloud.io/docker/compose/releases/download/1.22.0/doc ...

  5. 如何快速打通 Docker 镜像发布流程?

    作者 | 菜菜 责编 | 郭芮 YY妹:菜菜哥,我看了一下Docker相关的内容,但是还是有点迷糊. 菜菜:还有哪不明白呢? YY妹:如果我想用Docker实现所谓的云原生,我的项目该怎么发布呢? 菜 ...

  6. 【云原生】第二篇--容器管理工具 Docker生态架构及部署

    容器管理工具 Docker生态架构及部署 一.Docker生态架构 1.1 Docker Containers Are Everywhere 1.2 生态架构 1.2.1 Docker Host 1. ...

  7. Go 语言开发工具 LiteIDE X36 发布

    Go 语言开发工具 LiteIDE X36 发布,新增了编辑器路径导航工具栏,重构了 QuickOpen 插件,优化了快速打开文件和目录功能. ### 2019.03.15 Ver X36 * Lit ...

  8. 解决docker中发布到docker-hub上The push refers to a repository的报错原因。

    解决docker中发布到docker-hub上报错原因详细 一.报错 [root@Docker ~]# docker push jacker666/centos_update:1.0 The push ...

  9. 大话西游2人物属性预测工具1.0发布

    大话西游2人物属性预测工具1.0发布 大话西游2人物属性预测工具 http://pan.baidu.com/s/1eQuuaHW 本软件适用于大话西游2,可根据前世修炼法术修正.当前等级及装备情况来预 ...

最新文章

  1. intel python加速效果初探
  2. tensorflow越跑越慢_tensorflow如何解决越运行越慢的问题
  3. linux安装perl模块
  4. java 多线程之间通信_java多线程之间的通信
  5. 代码整洁之道 python_《代码整洁之道》与 Python 之禅
  6. YouTube双字幕显示
  7. win2003的密钥
  8. android自适应屏幕翻转,Android中正确自适应屏幕翻转
  9. 程序员常用英语词汇(018)
  10. Angular入门到精通系列教程(5)- 第三方UI库(Angular Material)
  11. ENDNOTE中使用Adobe打开PDF后提示“只读无法保存”
  12. 量子前沿英雄谱|引领量子科技三十年:斯坦福NTT教授Yoshihisa Yamamoto
  13. 魔兽WOW外网搭建的新手教程
  14. u盘计算机无法找到该项目,技术员教你win10系统删除文件时提示找不到该项目的方法...
  15. ubuntu16.04安装fcl库出现的问题
  16. 【环境配置】MySQL timestamp的默认值设置问题
  17. MapWindow Gis 组件代码示例:
  18. java打开word文件名乱码怎么解决_Word文档乱码怎么办?解决Word文档乱码的几种常见方法...
  19. oracle做全年日历表,Oracle之一份标准日历表的构建
  20. 曾经的我给初入大学的你们

热门文章

  1. United Plugins发布TrapTune人声插件
  2. Accurately Say CocaCola!
  3. 细说Java性能测试第一课 Jmeter导读
  4. 3月16日——3月20日课程表
  5. 计算机教学楼起名,给学校的教学楼起名字
  6. 网站优化-减少DNS查询
  7. 基于深度学习的印刷电路板瑕疵识别
  8. mysql实现悲观锁_mysql 悲观锁详解
  9. mysql如何加悲观锁_【mysql】关于悲观锁
  10. 操作系统实验二实验报告