diff --git a/Dockerfile b/Dockerfile index d4c74f1c9602934488b52a505de6a22dbdd4a99f..5f5de0e9aebb5dc6e0e73a7fd2af0f56d7e3a80a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,3 +1,7 @@ +# how to use +# docker build -t miniob . +# make sure docker has been installed + FROM centos:7 ARG HOME_DIR=/root @@ -6,16 +10,7 @@ ARG GIT_SOURCE=github ENV LANG=en_US.UTF-8 # install rpm -RUN yum install -y make git wget centos-release-scl scl-utils which - -# clone 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 -RUN git clone https://github.com/libevent/libevent -b release-2.1.12-stable -RUN git clone https://github.com/open-source-parsers/jsoncpp.git -RUN git clone https://github.com/google/googletest +RUN yum install -y make git wget centos-release-scl scl-utils which flex # prepare env RUN yum install -y devtoolset-11-gcc devtoolset-11-gcc-c++ @@ -26,28 +21,44 @@ 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 -# compile deps -RUN mkdir -p ${HOME_DIR}/deps/libevent/build \ - && mkdir -p ${HOME_DIR}/deps/googletest/build \ - && mkdir -p ${HOME_DIR}/deps/jsoncpp +# 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 -WORKDIR ${HOME_DIR}/deps/libevent/build -RUN cmake .. -DEVENT__DISABLE_OPENSSL=ON && make -j && make install +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/* -WORKDIR ${HOME_DIR}/deps/googletest/build -RUN cmake .. && make -j && make install +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/* -WORKDIR ${HOME_DIR}/deps/jsoncpp/build -RUN cmake -DJSONCPP_WITH_TESTS=OFF -DJSONCPP_WITH_POST_BUILD_UNITTEST=OFF .. && make -j && make install +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/* # clone miniob code RUN mkdir -p ${HOME_DIR}/source WORKDIR ${HOME_DIR}/source RUN git clone https://${GIT_SOURCE}.com/oceanbase/miniob +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 RUN mkdir -p ${HOME_DIR}/source/miniob/build WORKDIR ${HOME_DIR}/source/miniob/build -RUN cmake .. -DDEBUG=ON -DCMAKE_C_COMPILER=`which gcc` -DCMAKE_CXX_COMPILER=`which g++` \ - && make -j4 +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 WORKDIR ${HOME_DIR} diff --git a/README.md b/README.md index bafafed683a3772e641496a6dcf75ab75a4fe04d..d0aab9e58b2ce3d3078fb9237428e6b558d7844f 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,52 @@ -## Introduction -miniob设计的目标是让不熟悉数据库设计和实现的同学能够快速的了解与深入学习数据库内核,期望通过miniob相关训练之后,能够对各个数据库内核模块的功能与它们之间的关联有所了解,并能够在 -使用时,设计出高效的SQL。面向的对象主要是在校学生,并且诸多模块做了简化,比如不考虑并发操作。 +# Introduction +miniob 是 OceanBase与华中科技大学联合开发的、面向"零"基础数据库内核知识同学的一门数据库实现入门教程实践工具。 +miniob设计的目标是让不熟悉数据库设计和实现的同学能够快速的了解与深入学习数据库内核,期望通过相关训练之后,能够对各个数据库内核模块的功能与它们之间的关联有所了解,并能够在 +使用数据库时,设计出高效的SQL。面向的对象主要是在校学生,并且诸多模块做了简化,比如不考虑并发操作。 注意:此代码仅供学习使用,不考虑任何安全特性。 +[GitHub 首页](https://github.com/oceanbase/miniob) + # How to build -please refer to docs/how_to_build.md +直接在本地搭建开发环境,可以参考 docs/how_to_build.md。 + +# Docker + +首先要确保本地已经安装了Docker。 + +- 使用 Dockerfile 构建 + +Dockerfile: https://github.com/oceanbase/miniob/blob/main/Dockerfile + +```bash +# build +docker build -t miniob . +docker run -d --name='miniob' miniob:lastest + +# 进入容器,开发调试 +docker exec -it miniob bash +``` + +- 使用docker hub 镜像运行 + +```bash +docker run oceanbase/miniob +``` + +Docker环境说明: +docker基于`CentOS:7`制作。 + +镜像包含: + +- jsoncpp +- google test +- libevent +- flex +- bison(3.7) +- gcc/g++ (version=11) +- miniob 源码(/root/source/miniob) + +docker中在/root/source/miniob目录下载了github的源码,可以根据个人需要,下载自己仓库的源代码,也可以直接使用git pull 拉取最新代码。 +/root/source/miniob/build.sh 提供了一个编译脚本,以DEBUG模式编译miniob。 # miniob 题目 [miniob 题目](https://oceanbase-partner.github.io/lectures-on-dbms-implementation/miniob-topics)