You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@skywalking.apache.org by ha...@apache.org on 2023/12/19 06:25:31 UTC
(skywalking-banyandb) branch main updated: Combine banyand and bydbctl Dockerfile (#356)
This is an automated email from the ASF dual-hosted git repository.
hanahmily 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 234fe3e2 Combine banyand and bydbctl Dockerfile (#356)
234fe3e2 is described below
commit 234fe3e2e63fe3985ee598a4da8ab212d7475f05
Author: Huang Youliang <52...@users.noreply.github.com>
AuthorDate: Tue Dec 19 14:25:27 2023 +0800
Combine banyand and bydbctl Dockerfile (#356)
* Combine banyand and bydbctl Dockerfile
* Update CHANGES.md
---
.github/workflows/e2e.storage.yml | 2 +-
.github/workflows/publish-docker.yml | 2 +-
CHANGES.md | 1 +
Makefile | 18 +++++++++++++-----
banyand/Makefile | 1 -
bydbctl/Makefile | 3 ---
bydbctl/internal/cmd/health_check.go | 8 +++++++-
bydbctl/internal/cmd/health_check_test.go | 21 +++++++++++++++------
.dockerignore => docker/.dockerignore | 0
{banyand => docker}/Dockerfile | 6 +++++-
bydbctl/Dockerfile => docker/Makefile | 20 ++------------------
test/docker/base-compose.yml | 9 +++++++--
test/stress/docker-compose.yaml | 3 +--
test/stress/env | 1 -
test/stress/env.dev | 1 -
15 files changed, 53 insertions(+), 43 deletions(-)
diff --git a/.github/workflows/e2e.storage.yml b/.github/workflows/e2e.storage.yml
index 0446bb17..eb9bcebf 100644
--- a/.github/workflows/e2e.storage.yml
+++ b/.github/workflows/e2e.storage.yml
@@ -90,7 +90,7 @@ jobs:
uses: docker/setup-buildx-action@v1
- name: Build docker image
run: |
- make docker || make docker
+ make docker.build || make docker.build
docker image ls
- name: ${{ matrix.test.name }}
uses: apache/skywalking-infra-e2e@c7494f913e0b10d01884c840ec3fb1b0a844bcbe
diff --git a/.github/workflows/publish-docker.yml b/.github/workflows/publish-docker.yml
index 5e1a256f..b36e2810 100644
--- a/.github/workflows/publish-docker.yml
+++ b/.github/workflows/publish-docker.yml
@@ -77,7 +77,7 @@ jobs:
uses: docker/setup-buildx-action@v1
- name: Build docker image
run: |
- make docker || make docker
+ make docker.build || make docker.build
docker image ls
- name: Log in to the Container registry
uses: docker/login-action@v1.10.0
diff --git a/CHANGES.md b/CHANGES.md
index 4ef546dd..c504fc6b 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -21,6 +21,7 @@ Release Notes.
- Bump node to 20.9.
- Bump several tools.
- Bump all dependencies of Go and Node.
+- Combine banyand and bydbctl Dockerfile.
## 0.5.0
diff --git a/Makefile b/Makefile
index 37ba8a3e..b77efe5a 100644
--- a/Makefile
+++ b/Makefile
@@ -148,13 +148,21 @@ license-dep: default ## Fix license header issues
##@ Docker targets
-docker: TARGET=docker
-docker: PROJECTS:=$(PROJECTS)
-docker: default ## Run docker for all projects
+docker.build: TARGET=docker
+docker.build: DIR=docker
+docker.build:
+ $(MAKE) $(TARGET) -C $(DIR); \
+ if [ $$? -ne 0 ]; then \
+ exit 1; \
+ fi; \
docker.push: TARGET=docker.push
-docker.push: PROJECTS:=$(PROJECTS)
-docker.push: default ## Run docker.push for all projects
+docker.push: DIR=docker
+docker.push:
+ $(MAKE) $(TARGET) -C $(DIR); \
+ if [ $$? -ne 0 ]; then \
+ exit 1; \
+ fi; \
default:
@for PRJ in $(PROJECTS); do \
diff --git a/banyand/Makefile b/banyand/Makefile
index ca3f7604..65ab37df 100644
--- a/banyand/Makefile
+++ b/banyand/Makefile
@@ -32,6 +32,5 @@ include ../scripts/build/generate_go.mk
include ../scripts/build/build.mk
include ../scripts/build/test.mk
include ../scripts/build/lint.mk
-include ../scripts/build/docker.mk
include ../scripts/build/vendor.mk
include ../scripts/build/help.mk
diff --git a/bydbctl/Makefile b/bydbctl/Makefile
index 721922f4..8f8d7601 100644
--- a/bydbctl/Makefile
+++ b/bydbctl/Makefile
@@ -17,8 +17,6 @@
#
NAME := bydbctl
-IMG_NAME := skywalking-bydbctl
-
BUILD_DIR ?= build/bin
include ../scripts/build/version.mk
@@ -50,7 +48,6 @@ $(BUILDS):
.PHONY: release
release: $(BUILDS)
-include ../scripts/build/docker.mk
include ../scripts/build/test.mk
include ../scripts/build/lint.mk
include ../scripts/build/vendor.mk
diff --git a/bydbctl/internal/cmd/health_check.go b/bydbctl/internal/cmd/health_check.go
index a3f3b790..a701637c 100644
--- a/bydbctl/internal/cmd/health_check.go
+++ b/bydbctl/internal/cmd/health_check.go
@@ -24,6 +24,7 @@ import (
"os"
"time"
+ "github.com/go-resty/resty/v2"
"github.com/pkg/errors"
"github.com/spf13/cobra"
"google.golang.org/grpc"
@@ -45,6 +46,11 @@ func newHealthCheckCmd() *cobra.Command {
SilenceUsage: true,
RunE: func(_ *cobra.Command, _ []string) (err error) {
opts := make([]grpc.DialOption, 0, 1)
+ if grpcAddr == "" {
+ return rest(nil, func(request request) (*resty.Response, error) {
+ return request.req.Get(getPath("/api/healthz"))
+ }, yamlPrinter, enableTLS, insecure, grpcCert)
+ }
if enableTLS {
// #nosec G402
config := &tls.Config{
@@ -73,7 +79,7 @@ func newHealthCheckCmd() *cobra.Command {
return err
},
}
- healthCheckCmd.Flags().StringVarP(&grpcAddr, "grpc-addr", "", "localhost:17912", "Grpc server's address, the format is Domain:Port")
+ healthCheckCmd.Flags().StringVarP(&grpcAddr, "grpc-addr", "", "", "Grpc server's address, the format is Domain:Port")
bindTLSRelatedFlag(healthCheckCmd)
return healthCheckCmd
}
diff --git a/bydbctl/internal/cmd/health_check_test.go b/bydbctl/internal/cmd/health_check_test.go
index 72628c71..471c0c00 100644
--- a/bydbctl/internal/cmd/health_check_test.go
+++ b/bydbctl/internal/cmd/health_check_test.go
@@ -32,7 +32,7 @@ import (
var _ = Describe("health check after launching banyandb server", func() {
var deferFunc func()
- var grpcAddr, certFile string
+ var grpcAddr, httpAddr, certFile string
var rootCmd *cobra.Command
BeforeEach(func() {
_, basePath, _, _ := runtime.Caller(0)
@@ -41,12 +41,21 @@ var _ = Describe("health check after launching banyandb server", func() {
}
certFile = filepath.Join(basePath, "test/integration/standalone/other/testdata/server_cert.pem")
keyFile := filepath.Join(basePath, "test/integration/standalone/other/testdata/server_key.pem")
- grpcAddr, _, deferFunc = setup.StandaloneWithTLS(certFile, keyFile)
+ grpcAddr, httpAddr, deferFunc = setup.StandaloneWithTLS(certFile, keyFile)
rootCmd = &cobra.Command{Use: "root"}
cmd.RootCmdFlags(rootCmd)
})
- It("should pass", func() {
+ It("http health check should pass", func() {
+ rootCmd.SetArgs([]string{"health", "--addr", "http://" + httpAddr})
+ out := capturer.CaptureStdout(func() {
+ err := rootCmd.Execute()
+ Expect(err).NotTo(HaveOccurred())
+ })
+ Expect(out).To(ContainSubstring("SERVING"))
+ })
+
+ It("grpc health check should pass", func() {
rootCmd.SetArgs([]string{"health", "--grpc-addr", grpcAddr, "--grpc-cert", certFile, "--enable-tls", "true"})
out := capturer.CaptureStdout(func() {
err := rootCmd.Execute()
@@ -55,7 +64,7 @@ var _ = Describe("health check after launching banyandb server", func() {
Expect(out).To(ContainSubstring("connected"))
})
- It("should pass with insecure flag set", func() {
+ It("grpc health check should pass with insecure flag set", func() {
rootCmd.SetArgs([]string{"health", "--grpc-addr", grpcAddr, "--insecure", "true", "--enable-tls", "true"})
out := capturer.CaptureStdout(func() {
err := rootCmd.Execute()
@@ -64,7 +73,7 @@ var _ = Describe("health check after launching banyandb server", func() {
Expect(out).To(ContainSubstring("connected"))
})
- It("should fail without the proper cert", func() {
+ It("grpc health check should fail without the proper cert", func() {
rootCmd.SetArgs([]string{"health", "--grpc-addr", grpcAddr, "--enable-tls", "true"})
err := rootCmd.Execute()
Expect(err).To(HaveOccurred())
@@ -82,7 +91,7 @@ var _ = Describe("health check without launching banyandb server", func() {
cmd.RootCmdFlags(rootCmd)
})
- It("should fail", func() {
+ It("http health check should fail", func() {
rootCmd.SetArgs([]string{"health"})
err := rootCmd.Execute()
Expect(err).To(HaveOccurred())
diff --git a/.dockerignore b/docker/.dockerignore
similarity index 100%
rename from .dockerignore
rename to docker/.dockerignore
diff --git a/banyand/Dockerfile b/docker/Dockerfile
similarity index 88%
rename from banyand/Dockerfile
rename to docker/Dockerfile
index 9b964b29..563949e4 100644
--- a/banyand/Dockerfile
+++ b/docker/Dockerfile
@@ -40,6 +40,9 @@ FROM base AS builder
RUN --mount=target=. \
--mount=type=cache,target=/root/.cache/go-build \
BUILD_DIR=/out BUILD_TAGS=prometheus make -C banyand banyand-server-static
+RUN --mount=target=. \
+ --mount=type=cache,target=/root/.cache/go-build \
+ BUILD_DIR=/out make -C bydbctl build
FROM alpine:edge AS certs
RUN apk add --no-cache ca-certificates && update-ca-certificates
@@ -48,9 +51,10 @@ FROM busybox:stable-glibc
COPY --from=builder /out/banyand-server-static /banyand-server
COPY --from=certs /etc/ssl/certs /etc/ssl/certs
+COPY --from=builder /out/bydbctl /bydbctl
EXPOSE 17912
EXPOSE 17913
EXPOSE 6060
-ENTRYPOINT ["/banyand-server"]
+ENTRYPOINT ["/banyand-server"]
\ No newline at end of file
diff --git a/bydbctl/Dockerfile b/docker/Makefile
similarity index 68%
rename from bydbctl/Dockerfile
rename to docker/Makefile
index e681d074..bb89a358 100644
--- a/bydbctl/Dockerfile
+++ b/docker/Makefile
@@ -14,21 +14,5 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-FROM golang:1.21 AS base
-
-ENV GOPATH "/go"
-ENV GO111MODULE "on"
-WORKDIR /src
-COPY go.* ./
-RUN go mod download
-
-FROM base AS builder
-
-RUN --mount=target=. \
- --mount=type=cache,target=/root/.cache/go-build \
- BUILD_DIR=/out make -C bydbctl build
-
-FROM busybox:stable-glibc
-
-COPY --from=builder /out/bydbctl /bydbctl
-ENTRYPOINT ["/bydbctl"]
+IMG_NAME := skywalking-banyandb
+include ../scripts/build/docker.mk
\ No newline at end of file
diff --git a/test/docker/base-compose.yml b/test/docker/base-compose.yml
index da8159f7..49b4e3d5 100644
--- a/test/docker/base-compose.yml
+++ b/test/docker/base-compose.yml
@@ -21,7 +21,7 @@ services:
- 6060
command: standalone
healthcheck:
- test: wget --spider http://localhost:17913 || wget --spider --no-check-certificate https://localhost:17913 || exit 1
+ test: ["CMD", "./bydbctl", "health", "--addr=http://banyandb:17913"]
interval: 5s
timeout: 10s
retries: 120
@@ -34,7 +34,7 @@ services:
- 6060
command: liaison --etcd-endpoints=http://etcd:2379
healthcheck:
- test: wget --spider http://localhost:17913 || wget --spider --no-check-certificate https://localhost:17913 || exit 1
+ test: ["CMD", "./bydbctl", "health", "--addr=http://liaison:17913"]
interval: 5s
timeout: 10s
retries: 120
@@ -46,6 +46,11 @@ services:
- 2121
- 6060
command: data --etcd-endpoints=http://etcd:2379
+ healthcheck:
+ test: ["CMD", "./bydbctl", "health", "--grpc-addr=data:17912"]
+ interval: 5s
+ timeout: 10s
+ retries: 120
agent:
image: "ghcr.io/apache/skywalking-java/skywalking-java:${SW_AGENT_JAVA_COMMIT}-java8"
diff --git a/test/stress/docker-compose.yaml b/test/stress/docker-compose.yaml
index 2f69aa93..1278a19e 100644
--- a/test/stress/docker-compose.yaml
+++ b/test/stress/docker-compose.yaml
@@ -19,9 +19,8 @@ services:
file: ../docker/base-compose.yml
service: banyandb
build:
- dockerfile: ./banyand/Dockerfile
+ dockerfile: ./docker/Dockerfile
context: ../..
- target: ${TARGET}
volumes:
- ../..:/app:rw,delegated
# Uncomment below line to mount an external volume
diff --git a/test/stress/env b/test/stress/env
index 4d2c788b..1560b70d 100644
--- a/test/stress/env
+++ b/test/stress/env
@@ -29,5 +29,4 @@ SW_CTL_COMMIT=e684fae0107045fc23799146d62f04cb68bd5a3b
SW_OAP_COMMIT=e5c308d4358d5b02a658b8ad7f153aec99b8e63a
SW_AGENT_E2E_SERVICE_PROVIDER_COMMIT=828e6e2f2b57a0f06bb0d507e3296d2377943d9a
-TARGET=test
VUS=10
diff --git a/test/stress/env.dev b/test/stress/env.dev
index ab0e16cc..69aa1ce1 100644
--- a/test/stress/env.dev
+++ b/test/stress/env.dev
@@ -28,5 +28,4 @@ SW_CTL_COMMIT=e684fae0107045fc23799146d62f04cb68bd5a3b
SW_OAP_COMMIT=e5c308d4358d5b02a658b8ad7f153aec99b8e63a
SW_AGENT_E2E_SERVICE_PROVIDER_COMMIT=828e6e2f2b57a0f06bb0d507e3296d2377943d9a
-TARGET=dev
VUS=1