This is an automated email from the ASF dual-hosted git repository. wusheng pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/skywalking-banyandb.git
The following commit(s) were added to refs/heads/main by this push: new 50e35ea5 Support generate windows version docker (#403) 50e35ea5 is described below commit 50e35ea552bbfd56dc3be45f55dda9463178aac7 Author: mrproliu <741550...@qq.com> AuthorDate: Thu Mar 7 07:34:00 2024 +0000 Support generate windows version docker (#403) --- .github/workflows/publish-docker.yml | 26 +++++++++++++++++++++----- api/Makefile | 4 ++-- docker/Dockerfile.windows | 26 ++++++++++++++++++++++++++ pkg/Makefile | 1 + scripts/build/base.mk | 7 +++++++ scripts/build/build.mk | 4 ++-- scripts/build/docker.mk | 23 ++++++++++++++++++++--- scripts/build/generate_go.mk | 2 +- test/Makefile | 1 + 9 files changed, 81 insertions(+), 13 deletions(-) diff --git a/.github/workflows/publish-docker.yml b/.github/workflows/publish-docker.yml index b36e2810..1682761d 100644 --- a/.github/workflows/publish-docker.yml +++ b/.github/workflows/publish-docker.yml @@ -29,13 +29,17 @@ env: jobs: push-banyandb-image: if: github.repository == 'apache/skywalking-banyandb' - runs-on: ubuntu-latest + runs-on: ${{ matrix.target }}-latest permissions: contents: read packages: write timeout-minutes: 90 strategy: fail-fast: true + matrix: + target: + - ubuntu + - windows env: TAG: ${{ github.sha }} steps: @@ -68,14 +72,26 @@ jobs: uses: actions/setup-go@v3 with: go-version-file: 'go.mod' - - name: Update dependencies - if: steps.cache-go.outputs.cache-hit != 'true' + - name: Update dependencies on Linux + if: steps.cache-go.outputs.cache-hit != 'true' && matrix.target == 'ubuntu' run: GOPROXY=https://proxy.golang.org go mod download + - name: Update dependencies on Windows + if: steps.cache-go.outputs.cache-hit != 'true' && matrix.target == 'windows' + run: | + $env:GOPROXY="https://proxy.golang.org" + go mod download - name: Generate codes run: make generate - - name: Set up Docker Buildx + - name: Set up Docker Buildx on Linux + if: matrix.target == 'ubuntu' uses: docker/setup-buildx-action@v1 - - name: Build docker image + - name: Build binaries on Windows + if: matrix.target == 'windows' + run: | + $env:BUILD_TAGS="prometheus" + make -C banyand banyand-server-static + make -C bydbctl build + - name: Build docker image on Linux run: | make docker.build || make docker.build docker image ls diff --git a/api/Makefile b/api/Makefile index 22fb2ef3..ee39ccdb 100644 --- a/api/Makefile +++ b/api/Makefile @@ -46,5 +46,5 @@ $(BUF): @GOBIN=$(tool_bin) go install github.com/envoyproxy/protoc-gen-validate@$(PROTOC_GEN_VALIDATE_VERSION) generate: $(BUF) - @PATH=$(tool_bin):$(proto_dir) $(BUF) generate && \ - cp proto/api-reference.md $(root_dir)/docs + PATH=$(tool_bin):$(proto_dir):$$PATH; $(BUF) generate + cp proto/api-reference.md $(root_dir)/docs diff --git a/docker/Dockerfile.windows b/docker/Dockerfile.windows new file mode 100644 index 00000000..1755f514 --- /dev/null +++ b/docker/Dockerfile.windows @@ -0,0 +1,26 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +FROM mcr.microsoft.com/windows/servercore:ltsc2022 + +COPY banyand/build/bin/banyand-server-static c:\\banyand-server +COPY bydbctl/build/bin/bydbctl c:\\bydbctl + +EXPOSE 17912 +EXPOSE 17913 +EXPOSE 6060 + +ENTRYPOINT ["c:\\banyand-server"] \ No newline at end of file diff --git a/pkg/Makefile b/pkg/Makefile index bc53ec1b..e2b63c59 100644 --- a/pkg/Makefile +++ b/pkg/Makefile @@ -18,6 +18,7 @@ NAME := pkg +include ../scripts/build/version.mk include ../scripts/build/base.mk include ../scripts/build/generate_go.mk include ../scripts/build/test.mk diff --git a/scripts/build/base.mk b/scripts/build/base.mk index 58bd16f3..ffc59c0b 100644 --- a/scripts/build/base.mk +++ b/scripts/build/base.mk @@ -22,6 +22,13 @@ root_dir := $(mk_dir)../.. tool_bin := $(root_dir)/bin tool_include := "$(root_dir)/include" +ifeq ($(OS),Windows_NT) + # Using unix style path when running on Windows machine or Windows version Git Bash + tool_bin := $(subst \,/,$(tool_bin)) + # Match any drive letter and replace with lowercase version prefixed with '/' + tool_bin := $(shell echo $(tool_bin) | sed 's/\([A-Za-z]\):\/\?/\/\L\1\//g') +endif + # Retrieve git versioning details so we can add to our binary assets VERSION_PATH := github.com/apache/skywalking-banyandb/pkg/version ifdef RELEASE_VERSION diff --git a/scripts/build/build.mk b/scripts/build/build.mk index 13f1188c..cb6a9c3f 100644 --- a/scripts/build/build.mk +++ b/scripts/build/build.mk @@ -56,7 +56,7 @@ $(addprefix $(BUILD_DIR)/,$(DEBUG_BINARIES)): $(BUILD_DIR)/$(NAME)-%-debug: $(STATIC_BINARIES): $(NAME)-%-static: $(BUILD_DIR)/$(NAME)-%-static $(addprefix $(BUILD_DIR)/,$(STATIC_BINARIES)): $(BUILD_DIR)/$(NAME)-%-static: @echo "Building static binary" - CGO_ENABLED=0 GOOS=linux go build \ + CGO_ENABLED=0 go build \ -buildvcs=false \ -a --ldflags '${GO_LINK_VERSION} -extldflags "-static"' -tags "netgo $(BUILD_TAGS)" -installsuffix netgo \ -o $(BUILD_DIR)/$(NAME)-$*-static github.com/apache/skywalking-banyandb/$(SOURCE_DIR)/cmd/$* @@ -68,7 +68,7 @@ debug-static: $(DEBUG_STATIC_BINARIES) ## Build the debug static binaries $(DEBUG_STATIC_BINARIES): $(NAME)-%-debug-static: $(BUILD_DIR)/$(NAME)-%-debug-static $(addprefix $(BUILD_DIR)/,$(DEBUG_STATIC_BINARIES)): $(BUILD_DIR)/$(NAME)-%-debug-static: @echo "Building debug static binary" - CGO_ENABLED=0 GOOS=linux go build \ + CGO_ENABLED=0 go build \ -buildvcs=false \ -a --ldflags '${GO_LINK_VERSION} -extldflags "-static"' -tags "netgo $(BUILD_TAGS)" -gcflags='all=-N -l' -installsuffix netgo \ -o $(BUILD_DIR)/$(NAME)-$*-debug-static github.com/apache/skywalking-banyandb/$(SOURCE_DIR)/cmd/$* diff --git a/scripts/build/docker.mk b/scripts/build/docker.mk index d34df409..1ec5e2ef 100644 --- a/scripts/build/docker.mk +++ b/scripts/build/docker.mk @@ -31,15 +31,32 @@ IMG := $(HUB)/$(IMG_NAME):$(TAG) # Disable cache in CI environment ifeq (true,$(CI)) - DOCKER_BUILD_ARGS := $(DOCKER_BUILD_ARGS) --no-cache --load + ifeq ($(OS),Windows_NT) + # windows not support buildx, so no "--load" option + DOCKER_BUILD_ARGS := $(DOCKER_BUILD_ARGS) --no-cache + else + DOCKER_BUILD_ARGS := $(DOCKER_BUILD_ARGS) --no-cache --load + endif +endif + +DOCKER_FILE := Dockerfile +DOCKER_BUILD = docker buildx build +TIME = time +ifeq ($(OS),Windows_NT) + # build docker using other Dockerfile and docker build command + DOCKER_FILE = Dockerfile.windows + DOCKER_BUILD = docker build + # time is not support in the windows(CI environment) + TIME = endif .PHONY: docker docker: @echo "Build $(IMG)" - time docker buildx build $(DOCKER_BUILD_ARGS) -t $(IMG) -f Dockerfile .. + $(TIME) $(DOCKER_BUILD) $(DOCKER_BUILD_ARGS) -t $(IMG) -f $(DOCKER_FILE) .. .PHONY: docker.push docker.push: @echo "Push $(IMG)" - @time docker push $(IMG) + $(TIME) docker push $(IMG) + diff --git a/scripts/build/generate_go.mk b/scripts/build/generate_go.mk index 49edbca8..2523a1eb 100644 --- a/scripts/build/generate_go.mk +++ b/scripts/build/generate_go.mk @@ -24,4 +24,4 @@ $(MOCKGEN): .PHONY: generate generate: $(MOCKGEN) - @PATH=$(tool_bin):$$PATH; go generate ./... + PATH=$(tool_bin):$$PATH; go generate ./... diff --git a/test/Makefile b/test/Makefile index 8840363f..8730e7f3 100644 --- a/test/Makefile +++ b/test/Makefile @@ -18,6 +18,7 @@ NAME := test +include ../scripts/build/version.mk include ../scripts/build/base.mk include ../scripts/build/generate_go.mk include ../scripts/build/test.mk