使用dockcer生成thrift 0.9.2镜像

2018-04-03  本文已影响0人  Do_40

1.安装Docker

2.创建Dockerfile文件,内容如下

FROM debian:wheezy

RUN echo "deb http://mirrors.163.com/debian wheezy main non-free contrib\n \

    deb http://mirrors.163.com/debian wheezy-proposed-updates main contrib non-free\n \

    deb-src http://mirrors.163.com/debian wheezy main non-free contrib\n \

    deb-src http://mirrors.163.com/debian wheezy-proposed-updates main contrib non-free\n \

    deb http://mirrors.163.com/debian-security wheezy/updates main contrib non-free \n \

    deb-src http://mirrors.163.com/debian-security wheezy/updates main contrib non-free\n" > /etc/apt/sources.list

RUN buildDeps=" \

        automake \

        bison \

        curl \

        flex \

        g++ \

        libboost-dev \

        libboost-filesystem-dev \

        libboost-program-options-dev \

        libboost-system-dev \

        libboost-test-dev \

        libevent-dev \

        libssl-dev \

        libtool \

        make \

        pkg-config \

    "; \

    apt-get update && apt-get install -y --no-install-recommends $buildDeps && rm -rf /var/lib/apt/lists/*

COPY    thrift-0.9.2.tar.gz  thrift.tar.gz

RUN    mkdir -p /usr/src/thrift \

    && tar zxf thrift.tar.gz -C /usr/src/thrift --strip-components=1 \

    && rm thrift.tar.gz \

    && cd /usr/src/thrift \

    && ./configure  --without-python --without-cpp \

    && make \

    && make install \

    && cd / \

    && rm -rf /usr/src/thrift \

    && curl -k -sSL "https://storage.googleapis.com/golang/go1.4.linux-amd64.tar.gz" -o go.tar.gz \

    && tar xzf go.tar.gz \

    && rm go.tar.gz \

    && cp go/bin/gofmt /usr/bin/gofmt \

    && rm -rf go \

    && apt-get purge -y --auto-remove $buildDeps

CMD [ "thrift" ]

3.在Dockerfile所在目录运行命令如下 

docker build -t thrift:1 .

其中 thrift 表示该镜像REPOSITORY,1表示该镜像TAG

至此,已经生成thrift 0.9.2 的image,可以使用了

4.运行docker镜像

docker run thrift:1

5.编译thrift文件

thrift --gen java xxx.thrift

thrift --gen py xxx.thrift 

上一篇 下一篇

猜你喜欢

热点阅读