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?