Skip to content

Add devcontainer env #19

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
FROM centos:7.9.2009
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Based on my experience developing a dev container for OpenDAL, I recommend using mcr.microsoft.com/devcontainers/rust:bullseye and customizing it with post_create.sh. For more information, please visit https://github.com/apache/incubator-opendal/tree/main/.devcontainer.

  • All images are cached so users don't need to fetch them.
  • Those images are well-maintained and updated.
  • Those images handles many suck things related to users permission which is not easy (we tried and failed at OpenDAL).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, let me try


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
16 changes: 16 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -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
}
}
}
}
20 changes: 20 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)**
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tisonkun Do we allow personal image?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No. It's better to start a proposal build an image with approval of TiKV committers or maintainers instead of recommend a personal docker image in README.

@Smityz you can still mention it in the PR description and spread among social media, but TiKV may not endorse it like this.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree with you, and I will convert this PR to draft until someone builds an official docker image.

```bash
docker run -v $(pwd):/client-cpp \
registry.cn-hangzhou.aliyuncs.com/smityz/client-cpp:latest \
/bin/bash -c "make release"
```


## Run example

Expand Down