From e2b89e5ae2d07b4ec8b9bbbfe23f178e886b687b Mon Sep 17 00:00:00 2001 From: JimChenWYU Date: Wed, 25 Sep 2024 18:23:42 +0800 Subject: [PATCH] add docker builder --- .docker/Dockerfile.rockylinux9.3 | 35 ++++++++++++++++++++++++++++++++ .docker/Dockerfile.ubuntu22.04 | 27 ++++++++++++++++++++++++ Makefile | 18 ++++++++++++++-- 3 files changed, 78 insertions(+), 2 deletions(-) create mode 100644 .docker/Dockerfile.rockylinux9.3 create mode 100644 .docker/Dockerfile.ubuntu22.04 diff --git a/.docker/Dockerfile.rockylinux9.3 b/.docker/Dockerfile.rockylinux9.3 new file mode 100644 index 00000000..340b8419 --- /dev/null +++ b/.docker/Dockerfile.rockylinux9.3 @@ -0,0 +1,35 @@ +FROM m.daocloud.io/docker.io/library/rockylinux:9.3 AS builder + +ENV LANG C.UTF-8 + +RUN sed -e 's|^mirrorlist=|#mirrorlist=|g' \ + -e 's|^#baseurl=http://dl.rockylinux.org/$contentdir|baseurl=https://mirrors.ustc.edu.cn/rocky|g' \ + -i.bak \ + /etc/yum.repos.d/rocky-extras.repo \ + /etc/yum.repos.d/rocky.repo + +RUN dnf makecache + +RUN yum install wget git unzip gcc openssl-devel pkgconf-pkg-config -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 \ + && 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 + +COPY .docker/cargo.config.toml /root/.cargo/config.toml + +WORKDIR /root/s3-rustfs diff --git a/.docker/Dockerfile.ubuntu22.04 b/.docker/Dockerfile.ubuntu22.04 new file mode 100644 index 00000000..546b16b7 --- /dev/null +++ b/.docker/Dockerfile.ubuntu22.04 @@ -0,0 +1,27 @@ +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 + +COPY .docker/cargo.config.toml /root/.cargo/config.toml + +WORKDIR /root/s3-rustfs diff --git a/Makefile b/Makefile index 131a4f1c..b3b2e83a 100644 --- a/Makefile +++ b/Makefile @@ -5,11 +5,11 @@ DOCKER_CLI ?= docker IMAGE_NAME ?= rustfs:v1.0.0 CONTAINER_NAME ?= rustfs-dev -DOCKERFILE ?= $(shell pwd)/.docker/Dockerfile.devenv +DOCKERFILE_PATH = $(shell pwd)/.docker .PHONY: init-devenv init-devenv: - $(DOCKER_CLI) build -t $(IMAGE_NAME) -f $(DOCKERFILE) . + $(DOCKER_CLI) build -t $(IMAGE_NAME) -f $(DOCKERFILE_PATH)/Dockerfile.devenv . $(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) @@ -29,3 +29,17 @@ e2e-server: .PHONY: probe-e2e probe-e2e: sh $(shell pwd)/scripts/probe.sh + +# make BUILD_OS=ubuntu22.04 build +# in target/ubuntu22.04/release/rustfs + +# make BUILD_OS=rockylinux9.3 build +# in target/rockylinux9.3/release/rustfs +BUILD_OS ?= rockylinux9.3 +.PHONY: build +build: ROCKYLINUX_BUILD_IMAGE_NAME = $(BUILD_OS):v1 +build: ROCKYLINUX_BUILD_CONTAINER_NAME = rustfs-$(BUILD_OS)-build +build: BUILD_CMD = /root/.cargo/bin/cargo build --release --target-dir /root/s3-rustfs/target/$(BUILD_OS) +build: + $(DOCKER_CLI) build -t $(ROCKYLINUX_BUILD_IMAGE_NAME) -f $(DOCKERFILE_PATH)/Dockerfile.$(BUILD_OS) . + $(DOCKER_CLI) run --rm --name $(ROCKYLINUX_BUILD_CONTAINER_NAME) -v $(shell pwd):/root/s3-rustfs -it $(ROCKYLINUX_BUILD_IMAGE_NAME) $(BUILD_CMD)