diff --git a/.dockerignore b/.dockerignore index b3080b6..a03adfd 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,2 +1,25 @@ +# Binaries for programs and plugins +*.exe +*.exe~ +*.dll +*.so +*.dylib +# Test binary, built with `go test -c` +*.test + +# Output of the go coverage tool, specifically when used with LiteIDE +*.out + +# Dependency directories (remove the comment below to include it) +# vendor/ + +.idea +.vscode .docker + +/configs/config.yaml + +/docs +/runtime +/bin diff --git a/deploy/gitea/.gitea/workflows/deploy.yaml b/deploy/gitea/.gitea/workflows/deploy.yaml index a3d78b8..8edcef2 100644 --- a/deploy/gitea/.gitea/workflows/deploy.yaml +++ b/deploy/gitea/.gitea/workflows/deploy.yaml @@ -26,16 +26,14 @@ jobs: - uses: actions/checkout@v3 - name: Set up Go - uses: actions/setup-go@v4.2.0 + uses: actions/setup-go@v5 with: - go-version: '1.21' + go-version: '1.22' - name: Lint -# uses: golangci/golangci-lint-action@v3 - uses: actions/golangci-lint-action@v3 +# uses: golangci/golangci-lint-action@v6 + uses: actions/golangci-lint-action@v6 with: - version: latest - install-mode: goinstall args: --timeout=30m - name: Tests @@ -59,7 +57,7 @@ jobs: - name: Login to Docker Hub # uses: docker/login-action@v3 - uses: actions/login-action@v1 + uses: actions/login-action@v3 with: registry: ${{ env.REGISTRY }} username: ${{ secrets.DOCKER_USERNAME }} @@ -71,8 +69,8 @@ jobs: echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT - name: Docker build and push -# use: docker/build-push-action@v5 - uses: actions/build-push-action@v5 +# use: docker/build-push-action@v6 + uses: actions/build-push-action@v6 with: push: true file: deploy/docker/Dockerfile @@ -83,16 +81,16 @@ jobs: BASEIMAGE=${{ env.BASEIMAGE }}/debian:12-slim - name: Set up kubeconfig -# uses: azure/k8s-set-context@v3 - uses: actions/k8s-set-context@v3 +# uses: azure/k8s-set-context@v4 + uses: actions/k8s-set-context@v4 with: method: kubeconfig kubeconfig: ${{ secrets.KUBE_CONFIG }} context: k8s-context - name: Set up Helm -# uses: azure/setup-helm@v3 - uses: actions/setup-helm@v3.6 +# uses: azure/setup-helm@v4 + uses: actions/setup-helm@v4 with: version: 'v3.13.1' # default is latest (stable) @@ -100,8 +98,8 @@ jobs: env: APP_NAME: ${{ env.ENV=='prod' && env.APP_NAME || format('{0}-{1}', env.APP_NAME, env.ENV) }} DOMAIN: ${{ env.ENV=='prod' && env.DOMAIN || format('{0}.{1}', env.ENV, env.DOMAIN) }} - RESOURCE_CPU: ${{ env.ENV=='prod' && '500m' || '100m' }} - RESOURCE_MEMORY: ${{ env.ENV=='prod' && '512Mi' || '128Mi' }} + RESOURCE_CPU: ${{ env.ENV=='prod' && '200m' || '100m' }} + RESOURCE_MEMORY: ${{ env.ENV=='prod' && '256Mi' || '128Mi' }} AUTO_SCALING: ${{ env.ENV=='prod' && 'true' || 'false' }} AUTO_SCALING_MIN_REPLICAS: ${{ env.ENV=='prod' && '2' || '1' }} run: | @@ -116,4 +114,4 @@ jobs: --set resources.requests.cpu=$RESOURCE_CPU \ --set resources.requests.memory=$RESOURCE_MEMORY \ --set autoscaling.enabled=$AUTO_SCALING \ - --set autoscaling.minReplicas=$AUTO_SCALING_MIN_REPLICAS \ No newline at end of file + --set autoscaling.minReplicas=$AUTO_SCALING_MIN_REPLICAS diff --git a/deploy/gitea/.gitea/workflows/test.yaml b/deploy/gitea/.gitea/workflows/test.yaml index f7c3430..da6e184 100644 --- a/deploy/gitea/.gitea/workflows/test.yaml +++ b/deploy/gitea/.gitea/workflows/test.yaml @@ -21,16 +21,14 @@ jobs: - uses: actions/checkout@v3 - name: Set up Go - uses: actions/setup-go@v4.2.0 + uses: actions/setup-go@v5 with: go-version: '1.21' - name: Lint -# uses: golangci/golangci-lint-action@v3 - uses: actions/golangci-lint-action@v3 +# uses: golangci/golangci-lint-action@v6 + uses: actions/golangci-lint-action@v6 with: - version: latest - install-mode: goinstall args: --timeout=30m - name: Tests diff --git a/deploy/helm/values.yaml b/deploy/helm/values.yaml index 94c286b..fbc3401 100644 --- a/deploy/helm/values.yaml +++ b/deploy/helm/values.yaml @@ -73,11 +73,11 @@ resources: # resources, such as Minikube. If you do want to specify resources, uncomment the following # lines, adjust them as necessary, and remove the curly braces after 'resources:'. limits: - cpu: 1000m - memory: 1024Mi - requests: cpu: 500m - memory: 512Mi + memory: 521Mi + requests: + cpu: 200m + memory: 256Mi autoscaling: enabled: true diff --git a/examples/simple/.dockerignore b/examples/simple/.dockerignore new file mode 100644 index 0000000..a03adfd --- /dev/null +++ b/examples/simple/.dockerignore @@ -0,0 +1,25 @@ +# Binaries for programs and plugins +*.exe +*.exe~ +*.dll +*.so +*.dylib + +# Test binary, built with `go test -c` +*.test + +# Output of the go coverage tool, specifically when used with LiteIDE +*.out + +# Dependency directories (remove the comment below to include it) +# vendor/ + +.idea +.vscode +.docker + +/configs/config.yaml + +/docs +/runtime +/bin diff --git a/examples/simple/Makefile b/examples/simple/Makefile index 00c0f59..6c837c9 100644 --- a/examples/simple/Makefile +++ b/examples/simple/Makefile @@ -48,6 +48,7 @@ GOOS=linux GOARCH=amd64 APP_NAME=simple APP_VERSION=1.0.0 +LD_FLAGS=-w -s -X github.com/codfrm/cago/configs.Version=${APP_VERSION} SUFFIX= ifeq ($(GOOS),windows) @@ -55,5 +56,5 @@ ifeq ($(GOOS),windows) endif build: - GOOS=$(GOOS) GOARCH=$(GOARCH) go build -o bin/$(APP_NAME)_v$(APP_VERSION)$(SUFFIX) ./cmd/app - + GOOS=$(GOOS) GOARCH=$(GOARCH) go build -o bin/$(APP_NAME)_v$(APP_VERSION)$(SUFFIX) \ + -trimpath -ldflags "${LD_FLAGS}" ./cmd/app diff --git a/examples/simple/internal/task/queue/example.go b/examples/simple/internal/task/queue/example.go index fbd6d65..cd8774e 100644 --- a/examples/simple/internal/task/queue/example.go +++ b/examples/simple/internal/task/queue/example.go @@ -20,6 +20,7 @@ func PublishExample(ctx context.Context, msg *message.ExampleMsg) error { }) } +// SubscribeExample 订阅示例消息 func SubscribeExample(ctx context.Context, fn func(ctx context.Context, msg *message.ExampleMsg) error) error { _, err := broker.Default().Subscribe(ctx, ExampleTopic, func(ctx context.Context, event broker2.Event) error { msg := &message.ExampleMsg{}