diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index eb6d89d52..000000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,56 +0,0 @@ -name: benchmark -on: - push: - branches: - - master - - cluster - paths-ignore: - - "docs/**" - - "**.md" - - "dashboards/**" - - "deployment/**.yml" - pull_request: - types: - - opened - - synchronize - - reopened - - labeled - branches: - - master - - cluster - paths-ignore: - - "docs/**" - - "**.md" - - "dashboards/**" - - "deployment/**.yml" -permissions: - contents: read - packages: write - -concurrency: - group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} - cancel-in-progress: true - -jobs: - build-streamaggr-benchmark-image: - name: build - runs-on: ubuntu-latest - if: contains(github.event.pull_request.labels.*.name, 'streamaggr-benchmark') - steps: - - name: Code checkout - uses: actions/checkout@v4 - - - name: Login to GitHub Container Registry - uses: docker/login-action@v3 - with: - registry: ghcr.io - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - - name: Package VMAgent Docker image for benchmark - run: | - SKIP_SCRATCH_BUILD=true \ - DOCKER_BUILD_OPTS='--cache-to type=gha,mode=max --cache-from type=gha' \ - PKG_TAG=${{ github.event.pull_request.head.sha }} \ - DOCKER_REGISTRY=ghcr.io \ - TARGET_PLATFORM=linux/amd64 make publish-vmagent diff --git a/deployment/docker/Makefile b/deployment/docker/Makefile index 00ee79f5f..07470e48d 100644 --- a/deployment/docker/Makefile +++ b/deployment/docker/Makefile @@ -1,24 +1,19 @@ # All these commands must run from repository root. -DOCKER_REGISTRY ?= docker.io DOCKER_NAMESPACE ?= victoriametrics ROOT_IMAGE ?= alpine:3.20.1 ROOT_IMAGE_SCRATCH ?= scratch -SKIP_SCRATCH_BUILD ?= false CERTS_IMAGE := alpine:3.20.1 GO_BUILDER_IMAGE := golang:1.22.5-alpine BUILDER_IMAGE := local/builder:2.0.0-$(shell echo $(GO_BUILDER_IMAGE) | tr :/ __)-1 BASE_IMAGE := local/base:1.1.4-$(shell echo $(ROOT_IMAGE) | tr :/ __)-$(shell echo $(CERTS_IMAGE) | tr :/ __) DOCKER ?= docker -DOCKER_BUILD_OPTS ?= DOCKER_RUN ?= $(DOCKER) run DOCKER_BUILD ?= $(DOCKER) build DOCKER_COMPOSE ?= $(DOCKER) compose DOCKER_IMAGE_LS ?= $(DOCKER) image ls --format '{{.Repository}}:{{.Tag}}' -TARGET_PLATFORM ?= linux/amd64,linux/arm,linux/arm64,linux/ppc64le,linux/386 -COMMA := , package-base: ($(DOCKER_IMAGE_LS) | grep -q '$(BASE_IMAGE)$$') \ @@ -26,7 +21,6 @@ package-base: --build-arg root_image=$(ROOT_IMAGE) \ --build-arg certs_image=$(CERTS_IMAGE) \ --tag $(BASE_IMAGE) \ - $(DOCKER_BUILD_OPTS) \ deployment/docker/base package-builder: @@ -34,7 +28,6 @@ package-builder: || $(DOCKER_BUILD) \ --build-arg go_builder_image=$(GO_BUILDER_IMAGE) \ --tag $(BUILDER_IMAGE) \ - $(DOCKER_BUILD_OPTS) \ deployment/docker/builder app-via-docker: package-builder @@ -68,52 +61,57 @@ app-via-docker-windows: package-builder -o bin/$(APP_NAME)-windows$(APP_SUFFIX)-prod.exe $(PKG_PREFIX)/app/$(APP_NAME) package-via-docker: package-base - ($(DOCKER_IMAGE_LS) | grep -q '$(DOCKER_REGISTRY)/$(DOCKER_NAMESPACE)/$(APP_NAME):$(PKG_TAG)$(APP_SUFFIX)$(RACE)$$') || (\ + ($(DOCKER_IMAGE_LS) | grep -q '$(DOCKER_NAMESPACE)/$(APP_NAME):$(PKG_TAG)$(APP_SUFFIX)$(RACE)$$') || (\ $(MAKE) app-via-docker && \ $(DOCKER_BUILD) \ --build-arg src_binary=$(APP_NAME)$(APP_SUFFIX)-prod \ --build-arg base_image=$(BASE_IMAGE) \ - --tag $(DOCKER_REGISTRY)/$(DOCKER_NAMESPACE)/$(APP_NAME):$(PKG_TAG)$(APP_SUFFIX)$(RACE) \ + --tag $(DOCKER_NAMESPACE)/$(APP_NAME):$(PKG_TAG)$(APP_SUFFIX)$(RACE) \ -f app/$(APP_NAME)/deployment/Dockerfile bin) publish-via-docker: - $(eval TARGET_PLATFORMS := $(subst $(COMMA), ,$(TARGET_PLATFORM))) - $(MAKE_PARALLEL) $(foreach PLATFORM,$(TARGET_PLATFORMS),app-via-docker-$(subst /,-,$(PLATFORM))) + $(MAKE_PARALLEL) app-via-docker-linux-amd64 \ + app-via-docker-linux-arm \ + app-via-docker-linux-arm64 \ + app-via-docker-linux-ppc64le \ + app-via-docker-linux-386 $(DOCKER) buildx build \ - --platform=$(TARGET_PLATFORM) \ + --platform=linux/amd64,linux/arm,linux/arm64,linux/ppc64le,linux/386 \ --build-arg certs_image=$(CERTS_IMAGE) \ --build-arg root_image=$(ROOT_IMAGE) \ --build-arg APP_NAME=$(APP_NAME) \ - --tag $(DOCKER_REGISTRY)/$(DOCKER_NAMESPACE)/$(APP_NAME):$(PKG_TAG)$(RACE) \ - --tag $(DOCKER_REGISTRY)/$(DOCKER_NAMESPACE)/$(APP_NAME):$(LATEST_TAG)$(RACE) \ + --tag $(DOCKER_NAMESPACE)/$(APP_NAME):$(PKG_TAG)$(RACE) \ + --tag $(DOCKER_NAMESPACE)/$(APP_NAME):$(LATEST_TAG)$(RACE) \ -o type=image \ --provenance=false \ - $(DOCKER_BUILD_OPTS) \ -f app/$(APP_NAME)/multiarch/Dockerfile \ --push \ bin - $(if $(findstring $(SKIP_SCRATCH_BUILD),true),, \ - $(DOCKER) buildx build \ - --platform=$(TARGET_PLATFORM) \ - --build-arg certs_image=$(CERTS_IMAGE) \ - --build-arg root_image=$(ROOT_IMAGE_SCRATCH) \ - --build-arg APP_NAME=$(APP_NAME) \ - --tag $(DOCKER_NAMESPACE)/$(APP_NAME):$(PKG_TAG)$(RACE)-scratch \ - --tag $(DOCKER_NAMESPACE)/$(APP_NAME):$(LATEST_TAG)$(RACE)-scratch \ - -o type=image \ - --provenance=false \ - $(DOCKER_BUILD_OPTS) \ - -f app/$(APP_NAME)/multiarch/Dockerfile \ - --push \ - bin) - cd bin && rm -rf $(foreach PLATFORM,$(TARGET_PLATFORMS),$(APP_NAME)-$(subst /,-,$(PLATFORM))-prod) + $(DOCKER) buildx build \ + --platform=linux/amd64,linux/arm,linux/arm64,linux/ppc64le,linux/386 \ + --build-arg certs_image=$(CERTS_IMAGE) \ + --build-arg root_image=$(ROOT_IMAGE_SCRATCH) \ + --build-arg APP_NAME=$(APP_NAME) \ + --tag $(DOCKER_NAMESPACE)/$(APP_NAME):$(PKG_TAG)$(RACE)-scratch \ + --tag $(DOCKER_NAMESPACE)/$(APP_NAME):$(LATEST_TAG)$(RACE)-scratch \ + -o type=image \ + --provenance=false \ + -f app/$(APP_NAME)/multiarch/Dockerfile \ + --push \ + bin + cd bin && rm -rf \ + $(APP_NAME)-linux-amd64-prod \ + $(APP_NAME)-linux-arm-prod \ + $(APP_NAME)-linux-arm64-prod \ + $(APP_NAME)-linux-ppc64le-prod \ + $(APP_NAME)-linux-386-prod run-via-docker: package-via-docker $(DOCKER_RUN) -it --rm \ --user $(shell id -u):$(shell id -g) \ --net host \ $(DOCKER_OPTS) \ - $(DOCKER_REGISTRY)/$(DOCKER_NAMESPACE)/$(APP_NAME):$(PKG_TAG)$(APP_SUFFIX)$(RACE) $(ARGS) + $(DOCKER_NAMESPACE)/$(APP_NAME):$(PKG_TAG)$(APP_SUFFIX)$(RACE) $(ARGS) app-via-docker-goos-goarch: APP_SUFFIX='-$(GOOS)-$(GOARCH)' \