Dockerfile 2.8 KB
Newer Older
羽飞's avatar
docker  
羽飞 已提交
1 2 3 4
# how to use
# docker build -t miniob .
# make sure docker has been installed

羽飞's avatar
羽飞 已提交
5 6 7 8 9 10 11 12
FROM centos:7

ARG HOME_DIR=/root
ARG GIT_SOURCE=github

ENV LANG=en_US.UTF-8

# install rpm
羽飞's avatar
docker  
羽飞 已提交
13
RUN yum install -y make git wget centos-release-scl scl-utils which flex
羽飞's avatar
羽飞 已提交
14 15 16 17 18 19 20 21 22 23

# prepare env
RUN yum install -y devtoolset-11-gcc devtoolset-11-gcc-c++
WORKDIR ${HOME_DIR}
RUN echo "export PATH=/opt/rh/devtoolset-11/root/bin:/usr/local/oceanbase/devtools/bin:$PATH" >> .bashrc
RUN echo "export LD_LIBRARY_PATH=/usr/local/lib64:$LD_LIBRARY_PATH" >> .bashrc

ENV PATH /opt/rh/devtoolset-11/root/bin:/usr/local/oceanbase/devtools/bin:$PATH
ENV LD_LIBRARY_PATH /usr/local/lib64:$LD_LIBRARY_PATH

羽飞's avatar
docker  
羽飞 已提交
24 25 26 27 28
# clone deps and compile deps
RUN mkdir -p ${HOME_DIR}/deps
WORKDIR ${HOME_DIR}/deps
RUN wget http://yum-test.obvos.alibaba-inc.com/oceanbase/development-kit/el/7/x86_64/obdevtools-cmake-3.20.2-3.el7.x86_64.rpm \
    && rpm -ivh obdevtools-cmake-3.20.2-3.el7.x86_64.rpm && rm -f obdevtools-cmake-3.20.2-3.el7.x86_64.rpm
羽飞's avatar
羽飞 已提交
29

羽飞's avatar
docker  
羽飞 已提交
30 31 32 33
RUN git clone https://github.com/libevent/libevent  -b release-2.1.12-stable  \
    && mkdir -p ${HOME_DIR}/deps/libevent/build  \
    && cmake -DEVENT__DISABLE_OPENSSL=ON -B ${HOME_DIR}/deps/libevent/build ${HOME_DIR}/deps/libevent && make -C ${HOME_DIR}/deps/libevent/build -j install \
    && rm -rf ${HOME_DIR}/deps/*
羽飞's avatar
羽飞 已提交
34

羽飞's avatar
docker  
羽飞 已提交
35 36 37 38 39 40 41 42 43
RUN git clone https://github.com/open-source-parsers/jsoncpp.git \
    && mkdir -p ${HOME_DIR}/deps/jsoncpp/build \
    && cmake -DJSONCPP_WITH_TESTS=OFF -DJSONCPP_WITH_POST_BUILD_UNITTEST=OFF -B ${HOME_DIR}/deps/jsoncpp/build ${HOME_DIR}/deps/jsoncpp/ && make -C ${HOME_DIR}/deps/jsoncpp/build -j install \
    && rm -rf ${HOME_DIR}/deps/*

RUN git clone https://github.com/google/googletest \
    && mkdir -p ${HOME_DIR}/deps/googletest/build  \
    && cmake -B ${HOME_DIR}/deps/googletest/build ${HOME_DIR}/deps/googletest && make -C ${HOME_DIR}/deps/googletest/build -j install \
    && rm -rf ${HOME_DIR}/deps/*
羽飞's avatar
羽飞 已提交
44

羽飞's avatar
docker  
羽飞 已提交
45 46 47 48 49 50
RUN wget http://ftp.gnu.org/gnu/bison/bison-3.7.tar.gz \
    && tar xzvf bison-3.7.tar.gz \
    && cd bison-3.7 \
    && ./configure --prefix=/usr/local \
    && make -j install \
    && rm -rf ${HOME_DIR}/deps/*
羽飞's avatar
羽飞 已提交
51 52 53 54 55

# clone miniob code
RUN mkdir -p ${HOME_DIR}/source
WORKDIR ${HOME_DIR}/source
RUN git clone https://${GIT_SOURCE}.com/oceanbase/miniob
羽飞's avatar
docker  
羽飞 已提交
56
RUN echo "mkdir -p build && cd build && cmake .. -DDEBUG=ON -DCMAKE_C_COMPILER=`which gcc` -DCMAKE_CXX_COMPILER=`which g++` && make -j4" > ${HOME_DIR}/source/miniob/build.sh && chmod +x ${HOME_DIR}/source/miniob/build.sh
羽飞's avatar
羽飞 已提交
57 58
RUN mkdir -p ${HOME_DIR}/source/miniob/build
WORKDIR ${HOME_DIR}/source/miniob/build
羽飞's avatar
docker  
羽飞 已提交
59 60 61
RUN cmake -B ${HOME_DIR}/source/miniob/build -DDEBUG=ON -DCMAKE_C_COMPILER=`which gcc` -DCMAKE_CXX_COMPILER=`which g++` ${HOME_DIR}/source/miniob/ \
    && make -j4 \
    && rm -rf ${HOME_DIR}/source/miniob/build
羽飞's avatar
羽飞 已提交
62 63 64 65 66

WORKDIR ${HOME_DIR}

ENTRYPOINT exec /sbin/init