This is an automated email from the ASF dual-hosted git repository. alinsran pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/apisix-ingress-controller.git
The following commit(s) were added to refs/heads/master by this push: new 69db98c4 chore: remove adc binary from dockerfile (#2530) 69db98c4 is described below commit 69db98c4f8db674ddb15c746438963b684e91fcd Author: AlinsRan <alins...@apache.org> AuthorDate: Wed Aug 27 16:44:16 2025 +0800 chore: remove adc binary from dockerfile (#2530) --- .github/workflows/apisix-conformance-test.yml | 3 ++ .github/workflows/apisix-e2e-test.yml | 51 +++++++++++---------------- Dockerfile | 15 -------- Dockerfile.dev | 49 ------------------------- Makefile | 29 +++++++++------ test/e2e/scaffold/adc.go | 19 ++++++++-- 6 files changed, 59 insertions(+), 107 deletions(-) diff --git a/.github/workflows/apisix-conformance-test.yml b/.github/workflows/apisix-conformance-test.yml index d800252c..f6c7c9ca 100644 --- a/.github/workflows/apisix-conformance-test.yml +++ b/.github/workflows/apisix-conformance-test.yml @@ -61,6 +61,8 @@ jobs: provider_type: - apisix-standalone - apisix + env: + ADC_VERSION: "dev" runs-on: ubuntu-latest steps: - name: Checkout @@ -98,6 +100,7 @@ jobs: - name: Loading Docker Image to Kind Cluster run: | + make kind-load-adc-image make kind-load-ingress-image - name: Run Conformance Test diff --git a/.github/workflows/apisix-e2e-test.yml b/.github/workflows/apisix-e2e-test.yml index 7d293d2f..087963e3 100644 --- a/.github/workflows/apisix-e2e-test.yml +++ b/.github/workflows/apisix-e2e-test.yml @@ -32,26 +32,7 @@ concurrency: cancel-in-progress: true jobs: - prepare: - name: Prepare - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v4 - - - name: Setup Go Env - id: go - uses: actions/setup-go@v4 - with: - go-version: "1.23" - - - name: Install kind - run: | - go install sigs.k8s.io/kind@v0.23.0 - e2e-test: - needs: - - prepare strategy: matrix: provider_type: @@ -62,6 +43,8 @@ jobs: - networking.k8s.io fail-fast: false runs-on: ubuntu-latest + env: + ADC_VERSION: "dev" steps: - name: Checkout uses: actions/checkout@v4 @@ -73,6 +56,15 @@ jobs: with: go-version: "1.23" + - name: Setup Node.js + uses: actions/setup-node@v3 + with: + node-version: "*" + + - name: Install kind + run: | + go install sigs.k8s.io/kind@v0.23.0 + - name: Install ginkgo run: | make install-ginkgo @@ -83,32 +75,31 @@ jobs: ARCH: amd64 ENABLE_PROXY: "false" BASE_IMAGE_TAG: "debug" - ADC_VERSION: "dev" run: | echo "building images..." make build-image - - name: Extract adc binary - run: | - echo "Extracting adc binary..." - docker create --name adc-temp apache/apisix-ingress-controller:dev - docker cp adc-temp:/bin/adc /usr/local/bin/adc - docker rm adc-temp - chmod +x /usr/local/bin/adc - echo "ADC binary extracted to /usr/local/bin/adc" - - name: Launch Kind Cluster run: | make kind-up - name: Loading Docker Image to Kind Cluster run: | - make kind-load-ingress-image + make kind-load-images - name: Install Gateway API And CRDs run: | make install + - name: Extract adc binary + if: ${{ env.ADC_VERSION == 'dev' }} + run: | + docker create --name adc-temp ghcr.io/api7/adc:dev + docker cp adc-temp:main.js adc.js + docker rm adc-temp + node $(pwd)/adc.js -v + echo "ADC_BIN=node $(pwd)/adc.js" >> $GITHUB_ENV + - name: Run E2E test suite shell: bash env: diff --git a/Dockerfile b/Dockerfile index 9206a5ed..d6e8c6af 100644 --- a/Dockerfile +++ b/Dockerfile @@ -17,27 +17,12 @@ ARG BASE_IMAGE_TAG=nonroot -FROM debian:bullseye-slim AS deps -WORKDIR /workspace - -ARG TARGETARCH -ARG ADC_VERSION - -RUN apt update \ - && apt install -y wget \ - && wget https://github.com/api7/adc/releases/download/v${ADC_VERSION}/adc_${ADC_VERSION}_linux_${TARGETARCH}.tar.gz -O adc.tar.gz \ - && tar -zxvf adc.tar.gz \ - && mv adc /bin/adc \ - && rm -rf adc.tar.gz \ - && apt autoremove -y wget - FROM gcr.io/distroless/cc-debian12:${BASE_IMAGE_TAG} ARG TARGETARCH WORKDIR /app -COPY --from=deps /bin/adc /bin/adc COPY ./bin/apisix-ingress-controller_${TARGETARCH} ./apisix-ingress-controller ENTRYPOINT ["/app/apisix-ingress-controller"] diff --git a/Dockerfile.dev b/Dockerfile.dev deleted file mode 100644 index b9021996..00000000 --- a/Dockerfile.dev +++ /dev/null @@ -1,49 +0,0 @@ -# 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. - -ARG ENABLE_PROXY=false - -FROM node:22 AS node_builder - -ARG TARGETARCH - -WORKDIR /app - -RUN apt update \ - && apt install -y git \ - && git clone --depth 1 --branch main https://github.com/api7/adc.git \ - && cd adc \ - && corepack enable pnpm \ - && pnpm install \ - && NODE_ENV=production npx nx build cli \ - && node --experimental-sea-config apps/cli/node-sea.json \ - && npx ts-node apps/cli/scripts/download-node.ts \ - && npx postject ./node-binary/linux-${TARGETARCH} NODE_SEA_BLOB sea-prep.blob --sentinel-fuse NODE_SEA_FUSE_fce680ab2cc467b6e072b8b5df1996b2 \ - && mv ./node-binary/linux-${TARGETARCH} /bin/adc \ - && rm -rf /app - -FROM debian:bullseye-slim - -ARG TARGETARCH - -WORKDIR /app - -COPY --from=node_builder /bin/adc /bin/adc -COPY ./bin/apisix-ingress-controller_${TARGETARCH} ./apisix-ingress-controller - -ENTRYPOINT ["/app/apisix-ingress-controller"] -CMD ["-c", "/app/conf/config.yaml"] diff --git a/Makefile b/Makefile index 4f5b034b..6fbf9e8b 100644 --- a/Makefile +++ b/Makefile @@ -126,11 +126,11 @@ kind-e2e-test: kind-up build-image kind-load-images e2e-test # Utilize Kind or modify the e2e tests to load the image locally, enabling compatibility with other vendors. .PHONY: e2e-test -e2e-test: +e2e-test: adc go test $(TEST_DIR) -test.timeout=$(TEST_TIMEOUT) -v -ginkgo.v -ginkgo.focus="$(TEST_FOCUS)" -ginkgo.label-filter="$(TEST_LABEL)" .PHONY: ginkgo-e2e-test -ginkgo-e2e-test: +ginkgo-e2e-test: adc @ginkgo -cover -coverprofile=coverage.txt -r --randomize-all --randomize-suites --trace --focus=$(E2E_FOCUS) --nodes=$(E2E_NODES) --label-filter="$(TEST_LABEL)" $(TEST_DIR) .PHONY: install-ginkgo @@ -177,13 +177,14 @@ kind-load-ingress-image: .PHONY: kind-load-adc-image kind-load-adc-image: + @docker pull ghcr.io/api7/adc:$(ADC_VERSION) + @docker tag ghcr.io/api7/adc:$(ADC_VERSION) ghcr.io/api7/adc:dev @kind load docker-image ghcr.io/api7/adc:dev --name $(KIND_NAME) .PHONY: pull-infra-images pull-infra-images: @docker pull kennethreitz/httpbin:latest @docker pull jmalloc/echo-server:latest - @docker pull ghcr.io/api7/adc:dev ##@ Build @@ -209,11 +210,11 @@ build-multi-arch: .PHONY: build-multi-arch-image build-multi-arch-image: build-multi-arch # daemon.json: "features":{"containerd-snapshotter": true} - @docker buildx build --load --platform linux/amd64,linux/arm64 --build-arg ADC_VERSION=$(ADC_VERSION) -t $(IMG) . + @docker buildx build --load --platform linux/amd64,linux/arm64 -t $(IMG) . .PHONY: build-push-multi-arch-image build-push-multi-arch-image: build-multi-arch - @docker buildx build --push --platform linux/amd64,linux/arm64 --build-arg ADC_VERSION=$(ADC_VERSION) -t $(IMG) . + @docker buildx build --push --platform linux/amd64,linux/arm64 -t $(IMG) . .PHONY: run run: manifests generate fmt vet ## Run a controller from your host. @@ -224,12 +225,7 @@ run: manifests generate fmt vet ## Run a controller from your host. # More info: https://docs.docker.com/develop/develop-images/build_enhancements/ .PHONY: docker-build docker-build: set-e2e-goos build ## Build docker image with the manager. - @echo "Building with ADC_VERSION=$(ADC_VERSION)" - @if [ "$(strip $(ADC_VERSION))" = "dev" ]; then \ - $(CONTAINER_TOOL) build -t ${IMG} -f Dockerfile.dev . ; \ - else \ - $(CONTAINER_TOOL) build --build-arg ADC_VERSION=${ADC_VERSION} -t ${IMG} -f Dockerfile . ; \ - fi + $(CONTAINER_TOOL) build -t ${IMG} -f Dockerfile . .PHONY: docker-push docker-push: ## Push docker image with the manager. @@ -302,6 +298,7 @@ KUSTOMIZE ?= $(LOCALBIN)/kustomize CONTROLLER_GEN ?= $(LOCALBIN)/controller-gen ENVTEST ?= $(LOCALBIN)/setup-envtest GOLANGCI_LINT = $(LOCALBIN)/golangci-lint +ADC_BIN ?= $(LOCALBIN)/adc ## Tool Versions KUSTOMIZE_VERSION ?= v5.4.2 @@ -329,6 +326,16 @@ golangci-lint: $(GOLANGCI_LINT) ## Download golangci-lint locally if necessary. $(GOLANGCI_LINT): $(LOCALBIN) curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/HEAD/install.sh | sh -s $(GOLANGCI_LINT_VERSION) +.PHONY: adc +adc: $(ADC_BIN) ## Download adc locally if necessary. +$(ADC_BIN): +ifeq ($(ADC_VERSION),dev) + @echo "ADC_VERSION=dev, skip download" +else + curl -sSfL https://github.com/api7/adc/releases/download/v${ADC_VERSION}/adc_${ADC_VERSION}_${GOOS}_${GOARCH}.tar.gz \ + | tar -xz -C $(LOCALBIN) +endif + gofmt: ## Apply go fmt @gofmt -w -r 'interface{} -> any' . @gofmt -w -r 'FIt -> It' test diff --git a/test/e2e/scaffold/adc.go b/test/e2e/scaffold/adc.go index 38f741bd..96c9e3bd 100644 --- a/test/e2e/scaffold/adc.go +++ b/test/e2e/scaffold/adc.go @@ -23,6 +23,7 @@ import ( "errors" "os" "os/exec" + "strings" "time" "github.com/api7/gopkg/pkg/log" @@ -33,6 +34,20 @@ import ( "github.com/apache/apisix-ingress-controller/internal/adc/translator" ) +var ( + adcExec = "./bin/adc" + adcArgs []string +) + +func init() { + adc := os.Getenv("ADC_BIN") + if adc != "" && strings.Contains(adc, "node") { + parts := strings.Fields(adc) + adcExec = parts[0] + adcArgs = parts[1:] + } +} + // DataplaneResource defines the interface for accessing dataplane resources type DataplaneResource interface { Route() RouteResource @@ -124,7 +139,7 @@ func (a *adcDataplaneResource) dumpResources(ctx context.Context) (*translator.T _ = os.Remove(tempFile.Name()) }() - args := []string{"dump", "-o", tempFile.Name()} + args := append(adcArgs, []string{"dump", "-o", tempFile.Name()}...) if !a.tlsVerify { args = append(args, "--tls-skip-verify") } @@ -137,7 +152,7 @@ func (a *adcDataplaneResource) dumpResources(ctx context.Context) (*translator.T } var stdout, stderr bytes.Buffer - cmd := exec.CommandContext(ctxWithTimeout, "adc", args...) + cmd := exec.CommandContext(ctxWithTimeout, adcExec, args...) cmd.Stdout = &stdout cmd.Stderr = &stderr cmd.Env = append(cmd.Env, os.Environ()...)