From ef8995006d48296ee52348bbc9c954220cc67b44 Mon Sep 17 00:00:00 2001 From: JimChenWYU Date: Fri, 20 Sep 2024 16:11:49 +0800 Subject: [PATCH 1/6] =?UTF-8?q?=E7=BB=9F=E4=B8=80=E5=BC=80=E5=8F=91?= =?UTF-8?q?=E7=8E=AF=E5=A2=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Dockerfile | 39 +++++++++++++++++++++++++++++++++++++++ Makefile | 18 ++++++++++++++++++ 2 files changed, 57 insertions(+) create mode 100644 Dockerfile create mode 100644 Makefile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 000000000..2208355a5 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,39 @@ +FROM m.daocloud.io/docker.io/library/ubuntu:22.04 + +ENV LANG C.UTF-8 + +RUN sed -i s@http://.*archive.ubuntu.com@http://repo.huaweicloud.com@g /etc/apt/sources.list + +RUN apt-get clean && apt-get update && apt-get install wget git curl unzip gcc pkg-config libssl-dev -y + +# install protoc +RUN wget https://github.com/protocolbuffers/protobuf/releases/download/v27.0/protoc-27.0-linux-x86_64.zip \ + && unzip protoc-27.0-linux-x86_64.zip -d protoc3 \ + && mv protoc3/bin/* /usr/local/bin/ && chmod +x /usr/local/bin/protoc && mv protoc3/include/* /usr/local/include/ && rm -rf protoc-27.0-linux-x86_64.zip protoc3 + +# install flatc +RUN wget https://github.com/google/flatbuffers/releases/download/v24.3.25/Linux.flatc.binary.g++-13.zip \ + && unzip Linux.flatc.binary.g++-13.zip \ + && mv flatc /usr/local/bin/ && chmod +x /usr/local/bin/flatc && rm -rf Linux.flatc.binary.g++-13.zip + +# install rust +ENV RUSTUP_DIST_SERVER="https://rsproxy.cn" +ENV RUSTUP_UPDATE_ROOT="https://rsproxy.cn/rustup" +RUN curl -o rustup-init.sh --proto '=https' --tlsv1.2 -sSf https://rsproxy.cn/rustup-init.sh \ + && sh rustup-init.sh -y && rm -rf rustup-init.sh + +RUN echo "[source.crates-io]" > /root/.cargo/config.toml \ +&& echo "registry = \"https://github.com/rust-lang/crates.io-index\"" >> /root/.cargo/config.toml \ +&& echo "replace-with = \"rsproxy-sparse\"" >> /root/.cargo/config.toml \ +&& echo "[source.rsproxy]" >> /root/.cargo/config.toml \ +&& echo "registry = \"https://rsproxy.cn/crates.io-index\"" >> /root/.cargo/config.toml \ +&& echo "[source.rsproxy-sparse]" >> /root/.cargo/config.toml \ +&& echo "registry = \"sparse+https://rsproxy.cn/index/\"" >> /root/.cargo/config.toml \ +&& echo "[registries.rsproxy]" >> /root/.cargo/config.toml \ +&& echo "index = \"https://rsproxy.cn/crates.io-index\"" >> /root/.cargo/config.toml \ +&& echo "[net]" >> /root/.cargo/config.toml \ +&& echo "git-fetch-with-cli = true" >> /root/.cargo/config.toml + +WORKDIR /root/s3-rustfs + +CMD [ "bash", "-c", "while true; do sleep 1; done" ] diff --git a/Makefile b/Makefile new file mode 100644 index 000000000..d96c37069 --- /dev/null +++ b/Makefile @@ -0,0 +1,18 @@ +########### +# 远程开发,需要 VSCode 安装 Dev Containers, Remote SSH, Remote Explorer +# https://code.visualstudio.com/docs/remote/containers +########### +DOCKER_CLI ?= docker +IMAGE_NAME ?= rustfs:v1.0.0 +CONTAINER_NAME ?= rustfs-dev + +.PHONY: init +init: + $(DOCKER_CLI) build -t $(IMAGE_NAME) . + $(DOCKER_CLI) stop $(CONTAINER_NAME) + $(DOCKER_CLI) rm $(CONTAINER_NAME) + $(DOCKER_CLI) run -d --name $(CONTAINER_NAME) -p 9010:9010 -v $(shell pwd):/root/s3-rustfs -it $(IMAGE_NAME) + +.PHONY: start +start: + $(DOCKER_CLI) start $(CONTAINER_NAME) From f6be1cecfe62945e5d2044d4dab0a623213ae09a Mon Sep 17 00:00:00 2001 From: JimChenWYU Date: Fri, 20 Sep 2024 16:29:11 +0800 Subject: [PATCH 2/6] =?UTF-8?q?=E7=BB=9F=E4=B8=80=E5=BC=80=E5=8F=91?= =?UTF-8?q?=E7=8E=AF=E5=A2=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index d96c37069..6b3ef8eac 100644 --- a/Makefile +++ b/Makefile @@ -11,7 +11,7 @@ init: $(DOCKER_CLI) build -t $(IMAGE_NAME) . $(DOCKER_CLI) stop $(CONTAINER_NAME) $(DOCKER_CLI) rm $(CONTAINER_NAME) - $(DOCKER_CLI) run -d --name $(CONTAINER_NAME) -p 9010:9010 -v $(shell pwd):/root/s3-rustfs -it $(IMAGE_NAME) + $(DOCKER_CLI) run -d --name $(CONTAINER_NAME) -p 9010:9010 -p 9000:9000 -v $(shell pwd):/root/s3-rustfs -it $(IMAGE_NAME) .PHONY: start start: From 8381eb96d5e223d133855b86f1ed9788291e9c37 Mon Sep 17 00:00:00 2001 From: JimChenWYU Date: Mon, 23 Sep 2024 16:48:53 +0800 Subject: [PATCH 3/6] =?UTF-8?q?=E8=AE=BE=E7=BD=AEci=E6=B5=81=E6=B0=B4?= =?UTF-8?q?=E7=BA=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Dockerfile => .docker/Dockerfile.devenv | 12 +----- .docker/cargo.config.toml | 13 +++++++ .github/workflows/rust.yml | 50 +++++++++++++++++++++---- Makefile | 11 ++++-- 4 files changed, 65 insertions(+), 21 deletions(-) rename Dockerfile => .docker/Dockerfile.devenv (60%) create mode 100644 .docker/cargo.config.toml diff --git a/Dockerfile b/.docker/Dockerfile.devenv similarity index 60% rename from Dockerfile rename to .docker/Dockerfile.devenv index 2208355a5..e95027d2e 100644 --- a/Dockerfile +++ b/.docker/Dockerfile.devenv @@ -22,17 +22,7 @@ ENV RUSTUP_UPDATE_ROOT="https://rsproxy.cn/rustup" RUN curl -o rustup-init.sh --proto '=https' --tlsv1.2 -sSf https://rsproxy.cn/rustup-init.sh \ && sh rustup-init.sh -y && rm -rf rustup-init.sh -RUN echo "[source.crates-io]" > /root/.cargo/config.toml \ -&& echo "registry = \"https://github.com/rust-lang/crates.io-index\"" >> /root/.cargo/config.toml \ -&& echo "replace-with = \"rsproxy-sparse\"" >> /root/.cargo/config.toml \ -&& echo "[source.rsproxy]" >> /root/.cargo/config.toml \ -&& echo "registry = \"https://rsproxy.cn/crates.io-index\"" >> /root/.cargo/config.toml \ -&& echo "[source.rsproxy-sparse]" >> /root/.cargo/config.toml \ -&& echo "registry = \"sparse+https://rsproxy.cn/index/\"" >> /root/.cargo/config.toml \ -&& echo "[registries.rsproxy]" >> /root/.cargo/config.toml \ -&& echo "index = \"https://rsproxy.cn/crates.io-index\"" >> /root/.cargo/config.toml \ -&& echo "[net]" >> /root/.cargo/config.toml \ -&& echo "git-fetch-with-cli = true" >> /root/.cargo/config.toml +COPY .docker/cargo.config.toml /root/.cargo/config.toml WORKDIR /root/s3-rustfs diff --git a/.docker/cargo.config.toml b/.docker/cargo.config.toml new file mode 100644 index 000000000..ef2fa863f --- /dev/null +++ b/.docker/cargo.config.toml @@ -0,0 +1,13 @@ +[source.crates-io] +registry = "https://github.com/rust-lang/crates.io-index" +replace-with = 'rsproxy-sparse' + +[source.rsproxy] +registry = "https://rsproxy.cn/crates.io-index" +[registries.rsproxy] +index = "https://rsproxy.cn/crates.io-index" +[source.rsproxy-sparse] +registry = "sparse+https://rsproxy.cn/index/" + +[net] +git-fetch-with-cli = true diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 9fd45e090..aa949c986 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -1,8 +1,8 @@ name: Rust on: + workflow_dispatch: push: - branches: [ "main" ] pull_request: branches: [ "main" ] @@ -11,12 +11,48 @@ env: jobs: build: - runs-on: ubuntu-latest + strategy: + matrix: + rust: + - stable + - beta + - nightly steps: - - uses: actions/checkout@v4 - - name: Build - run: cargo build --verbose - - name: Run tests - run: cargo test --verbose + - name: cache protoc bin + id: cache-protoc-action + uses: actions/cache@v3 + env: + cache-name: cache-protoc-action-bin + with: + path: /usr/local/bin/protoc + key: ${{ runner.os }}-build-${{ env.cache-name }}-v0.0.1 + + - name: install protoc + if: steps.cache-protoc-action.outputs.cache-hit != 'true' + run: | + wget https://github.com/protocolbuffers/protobuf/releases/download/v27.0/protoc-27.0-linux-x86_64.zip + unzip protoc-27.0-linux-x86_64.zip -d protoc3 + mv protoc3/bin/* /usr/local/bin/ + chmod +x /usr/local/bin/protoc + rm -rf protoc-27.0-linux-x86_64.zip protoc3 + + - uses: actions/checkout@v2 + + - uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: ${{ matrix.rust }} + override: true + components: rustfmt, clippy + + - uses: actions-rs/cargo@v1 + with: + command: build + args: --verbose + + - uses: actions-rs/cargo@v1 + with: + command: test + args: --all --verbose diff --git a/Makefile b/Makefile index 6b3ef8eac..6f05e92b5 100644 --- a/Makefile +++ b/Makefile @@ -5,10 +5,11 @@ DOCKER_CLI ?= docker IMAGE_NAME ?= rustfs:v1.0.0 CONTAINER_NAME ?= rustfs-dev +DOCKERFILE ?= $(shell pwd)/.docker/Dockerfile.devenv -.PHONY: init -init: - $(DOCKER_CLI) build -t $(IMAGE_NAME) . +.PHONY: init-devenv +init-devenv: + $(DOCKER_CLI) build -t $(IMAGE_NAME) -f $(DOCKERFILE) . $(DOCKER_CLI) stop $(CONTAINER_NAME) $(DOCKER_CLI) rm $(CONTAINER_NAME) $(DOCKER_CLI) run -d --name $(CONTAINER_NAME) -p 9010:9010 -p 9000:9000 -v $(shell pwd):/root/s3-rustfs -it $(IMAGE_NAME) @@ -16,3 +17,7 @@ init: .PHONY: start start: $(DOCKER_CLI) start $(CONTAINER_NAME) + +.PHONY: stop +stop: + $(DOCKER_CLI) stop $(CONTAINER_NAME) From ed6fde5e4d43bd44a55e9cd895a71b9383202e52 Mon Sep 17 00:00:00 2001 From: JimChenWYU Date: Mon, 23 Sep 2024 18:05:18 +0800 Subject: [PATCH 4/6] print protoc version --- .github/workflows/rust.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index aa949c986..cd5d532c4 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -37,7 +37,10 @@ jobs: mv protoc3/bin/* /usr/local/bin/ chmod +x /usr/local/bin/protoc rm -rf protoc-27.0-linux-x86_64.zip protoc3 - + + - name: print protoc version + run: protoc --version + - uses: actions/checkout@v2 - uses: actions-rs/toolchain@v1 From 54101378e3420c8f9f4483a4971f81d2557c3dba Mon Sep 17 00:00:00 2001 From: JimChenWYU Date: Mon, 23 Sep 2024 18:11:08 +0800 Subject: [PATCH 5/6] install flatc --- .github/workflows/rust.yml | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index cd5d532c4..83f4d280a 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -40,7 +40,25 @@ jobs: - name: print protoc version run: protoc --version - + + - name: cache flatc bin + id: cache-flatc-action + uses: actions/cache@v3 + env: + cache-name: cache-flatc-action-bin + with: + path: /usr/local/bin/flatc + key: ${{ runner.os }}-build-${{ env.cache-name }}-v0.0.1 + + - name: install flatc + if: steps.cache-flatc-action.outputs.cache-hit != 'true' + run: | + wget https://github.com/google/flatbuffers/releases/download/v24.3.25/Linux.flatc.binary.g++-13.zip + unzip Linux.flatc.binary.g++-13.zip + mv flatc /usr/local/bin/ + chmod +x /usr/local/bin/flatc + rm -rf Linux.flatc.binary.g++-13.zip + - uses: actions/checkout@v2 - uses: actions-rs/toolchain@v1 From 8cce210d640351585bab191482f3693813fd5d17 Mon Sep 17 00:00:00 2001 From: JimChenWYU Date: Mon, 23 Sep 2024 18:44:55 +0800 Subject: [PATCH 6/6] install flatc --- .github/workflows/rust.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 83f4d280a..6dd5d7024 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -71,9 +71,8 @@ jobs: - uses: actions-rs/cargo@v1 with: command: build - args: --verbose - uses: actions-rs/cargo@v1 with: command: test - args: --all --verbose + args: --all