diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile new file mode 100644 index 0000000..d821370 --- /dev/null +++ b/.devcontainer/Dockerfile @@ -0,0 +1,24 @@ +FROM centos:7.9.2009 + +RUN yum -y install centos-release-scl \ + epel-release; \ + yum -y install devtoolset-7-gcc \ + devtoolset-7-gcc-c++ \ + python3 \ + make \ + libtool \ + openssl-devel \ + yum clean all; \ + rm -rf /var/cache/yum; + +ENV PATH /opt/rh/devtoolset-7/root/bin/:$PATH +RUN pip3 install --upgrade pip --no-cache-dir && pip3 install --no-cache-dir cmake==3.26.4 -i https://pypi.tuna.tsinghua.edu.cn/simple + +ENV RUSTUP_HOME=/usr/local/rustup CARGO_HOME=/usr/local/cargo +ENV PATH $CARGO_HOME/bin:$PATH +RUN mkdir -p "$CARGO_HOME" && mkdir -p "$RUSTUP_HOME" && \ + curl https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain 1.70.0 && \ + chmod -R a=rwX $CARGO_HOME +RUN cargo install cxxbridge-cmd --version 1.0.18 + +WORKDIR /client-cpp diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 0000000..8bd1472 --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,16 @@ +{ + "name": "tikv/cpp-client", + "dockerFile": "Dockerfile", + "postAttachCommand": "bash", + "customizations": { + "vscode": { + "extensions": [ + "cschleiden.vscode-github-actions", + "vadimcn.vscode-lldb" + ], + "settings": { + "editor.formatOnSave": true + } + } + } +} diff --git a/README.md b/README.md index 1cc10dc..c8554fb 100644 --- a/README.md +++ b/README.md @@ -9,6 +9,7 @@ This client is still in the stage of prove-of-concept and under heavy developmen ## Build +### Local Build ```bash # cxxbridge-cmd 1.0.18 requires rustc 1.48+ and c++17 or newer cargo install cxxbridge-cmd --force --version 1.0.18 @@ -23,6 +24,25 @@ Otherwise, you can build release version by the following. The library will be i ```bash make release ``` +### Docker build +**Way 1: Use Visual Studio Code Dev Container** +you can use the dev container to build the project, just open the project in VSCode and press `F1` and select `Dev Containers: Reopen in Container` to open the project in dev container. + +**Way 2: Build Docker Locally Then Compile** +```bash +docker build -t tikv/client-cpp:latest \ -f .devcontainer/Dockerfile . +docker run -v $(pwd):/client-cpp \ + tikv/client-cpp:latest \ + /bin/bash -c "make release" +``` + +**Way3: Use Image to Compile(Image is NOT Official)** +```bash +docker run -v $(pwd):/client-cpp \ + registry.cn-hangzhou.aliyuncs.com/smityz/client-cpp:latest \ + /bin/bash -c "make release" +``` + ## Run example