Skip to content

Commit 69db98c

Browse files
authored
chore: remove adc binary from dockerfile (#2530)
1 parent 75d068a commit 69db98c

File tree

6 files changed

+59
-107
lines changed

6 files changed

+59
-107
lines changed

.github/workflows/apisix-conformance-test.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ jobs:
6161
provider_type:
6262
- apisix-standalone
6363
- apisix
64+
env:
65+
ADC_VERSION: "dev"
6466
runs-on: ubuntu-latest
6567
steps:
6668
- name: Checkout
@@ -98,6 +100,7 @@ jobs:
98100
99101
- name: Loading Docker Image to Kind Cluster
100102
run: |
103+
make kind-load-adc-image
101104
make kind-load-ingress-image
102105
103106
- name: Run Conformance Test

.github/workflows/apisix-e2e-test.yml

Lines changed: 21 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -32,26 +32,7 @@ concurrency:
3232
cancel-in-progress: true
3333

3434
jobs:
35-
prepare:
36-
name: Prepare
37-
runs-on: ubuntu-latest
38-
steps:
39-
- name: Checkout
40-
uses: actions/checkout@v4
41-
42-
- name: Setup Go Env
43-
id: go
44-
uses: actions/setup-go@v4
45-
with:
46-
go-version: "1.23"
47-
48-
- name: Install kind
49-
run: |
50-
go install sigs.k8s.io/kind@v0.23.0
51-
5235
e2e-test:
53-
needs:
54-
- prepare
5536
strategy:
5637
matrix:
5738
provider_type:
@@ -62,6 +43,8 @@ jobs:
6243
- networking.k8s.io
6344
fail-fast: false
6445
runs-on: ubuntu-latest
46+
env:
47+
ADC_VERSION: "dev"
6548
steps:
6649
- name: Checkout
6750
uses: actions/checkout@v4
@@ -73,6 +56,15 @@ jobs:
7356
with:
7457
go-version: "1.23"
7558

59+
- name: Setup Node.js
60+
uses: actions/setup-node@v3
61+
with:
62+
node-version: "*"
63+
64+
- name: Install kind
65+
run: |
66+
go install sigs.k8s.io/kind@v0.23.0
67+
7668
- name: Install ginkgo
7769
run: |
7870
make install-ginkgo
@@ -83,32 +75,31 @@ jobs:
8375
ARCH: amd64
8476
ENABLE_PROXY: "false"
8577
BASE_IMAGE_TAG: "debug"
86-
ADC_VERSION: "dev"
8778
run: |
8879
echo "building images..."
8980
make build-image
9081
91-
- name: Extract adc binary
92-
run: |
93-
echo "Extracting adc binary..."
94-
docker create --name adc-temp apache/apisix-ingress-controller:dev
95-
docker cp adc-temp:/bin/adc /usr/local/bin/adc
96-
docker rm adc-temp
97-
chmod +x /usr/local/bin/adc
98-
echo "ADC binary extracted to /usr/local/bin/adc"
99-
10082
- name: Launch Kind Cluster
10183
run: |
10284
make kind-up
10385
10486
- name: Loading Docker Image to Kind Cluster
10587
run: |
106-
make kind-load-ingress-image
88+
make kind-load-images
10789
10890
- name: Install Gateway API And CRDs
10991
run: |
11092
make install
11193
94+
- name: Extract adc binary
95+
if: ${{ env.ADC_VERSION == 'dev' }}
96+
run: |
97+
docker create --name adc-temp ghcr.io/api7/adc:dev
98+
docker cp adc-temp:main.js adc.js
99+
docker rm adc-temp
100+
node $(pwd)/adc.js -v
101+
echo "ADC_BIN=node $(pwd)/adc.js" >> $GITHUB_ENV
102+
112103
- name: Run E2E test suite
113104
shell: bash
114105
env:

Dockerfile

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -17,27 +17,12 @@
1717

1818
ARG BASE_IMAGE_TAG=nonroot
1919

20-
FROM debian:bullseye-slim AS deps
21-
WORKDIR /workspace
22-
23-
ARG TARGETARCH
24-
ARG ADC_VERSION
25-
26-
RUN apt update \
27-
&& apt install -y wget \
28-
&& wget https://github.com/api7/adc/releases/download/v${ADC_VERSION}/adc_${ADC_VERSION}_linux_${TARGETARCH}.tar.gz -O adc.tar.gz \
29-
&& tar -zxvf adc.tar.gz \
30-
&& mv adc /bin/adc \
31-
&& rm -rf adc.tar.gz \
32-
&& apt autoremove -y wget
33-
3420
FROM gcr.io/distroless/cc-debian12:${BASE_IMAGE_TAG}
3521

3622
ARG TARGETARCH
3723

3824
WORKDIR /app
3925

40-
COPY --from=deps /bin/adc /bin/adc
4126
COPY ./bin/apisix-ingress-controller_${TARGETARCH} ./apisix-ingress-controller
4227

4328
ENTRYPOINT ["/app/apisix-ingress-controller"]

Dockerfile.dev

Lines changed: 0 additions & 49 deletions
This file was deleted.

Makefile

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -126,11 +126,11 @@ kind-e2e-test: kind-up build-image kind-load-images e2e-test
126126

127127
# Utilize Kind or modify the e2e tests to load the image locally, enabling compatibility with other vendors.
128128
.PHONY: e2e-test
129-
e2e-test:
129+
e2e-test: adc
130130
go test $(TEST_DIR) -test.timeout=$(TEST_TIMEOUT) -v -ginkgo.v -ginkgo.focus="$(TEST_FOCUS)" -ginkgo.label-filter="$(TEST_LABEL)"
131131

132132
.PHONY: ginkgo-e2e-test
133-
ginkgo-e2e-test:
133+
ginkgo-e2e-test: adc
134134
@ginkgo -cover -coverprofile=coverage.txt -r --randomize-all --randomize-suites --trace --focus=$(E2E_FOCUS) --nodes=$(E2E_NODES) --label-filter="$(TEST_LABEL)" $(TEST_DIR)
135135

136136
.PHONY: install-ginkgo
@@ -177,13 +177,14 @@ kind-load-ingress-image:
177177

178178
.PHONY: kind-load-adc-image
179179
kind-load-adc-image:
180+
@docker pull ghcr.io/api7/adc:$(ADC_VERSION)
181+
@docker tag ghcr.io/api7/adc:$(ADC_VERSION) ghcr.io/api7/adc:dev
180182
@kind load docker-image ghcr.io/api7/adc:dev --name $(KIND_NAME)
181183

182184
.PHONY: pull-infra-images
183185
pull-infra-images:
184186
@docker pull kennethreitz/httpbin:latest
185187
@docker pull jmalloc/echo-server:latest
186-
@docker pull ghcr.io/api7/adc:dev
187188

188189
##@ Build
189190

@@ -209,11 +210,11 @@ build-multi-arch:
209210
.PHONY: build-multi-arch-image
210211
build-multi-arch-image: build-multi-arch
211212
# daemon.json: "features":{"containerd-snapshotter": true}
212-
@docker buildx build --load --platform linux/amd64,linux/arm64 --build-arg ADC_VERSION=$(ADC_VERSION) -t $(IMG) .
213+
@docker buildx build --load --platform linux/amd64,linux/arm64 -t $(IMG) .
213214

214215
.PHONY: build-push-multi-arch-image
215216
build-push-multi-arch-image: build-multi-arch
216-
@docker buildx build --push --platform linux/amd64,linux/arm64 --build-arg ADC_VERSION=$(ADC_VERSION) -t $(IMG) .
217+
@docker buildx build --push --platform linux/amd64,linux/arm64 -t $(IMG) .
217218

218219
.PHONY: run
219220
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.
224225
# More info: https://docs.docker.com/develop/develop-images/build_enhancements/
225226
.PHONY: docker-build
226227
docker-build: set-e2e-goos build ## Build docker image with the manager.
227-
@echo "Building with ADC_VERSION=$(ADC_VERSION)"
228-
@if [ "$(strip $(ADC_VERSION))" = "dev" ]; then \
229-
$(CONTAINER_TOOL) build -t ${IMG} -f Dockerfile.dev . ; \
230-
else \
231-
$(CONTAINER_TOOL) build --build-arg ADC_VERSION=${ADC_VERSION} -t ${IMG} -f Dockerfile . ; \
232-
fi
228+
$(CONTAINER_TOOL) build -t ${IMG} -f Dockerfile .
233229

234230
.PHONY: docker-push
235231
docker-push: ## Push docker image with the manager.
@@ -302,6 +298,7 @@ KUSTOMIZE ?= $(LOCALBIN)/kustomize
302298
CONTROLLER_GEN ?= $(LOCALBIN)/controller-gen
303299
ENVTEST ?= $(LOCALBIN)/setup-envtest
304300
GOLANGCI_LINT = $(LOCALBIN)/golangci-lint
301+
ADC_BIN ?= $(LOCALBIN)/adc
305302

306303
## Tool Versions
307304
KUSTOMIZE_VERSION ?= v5.4.2
@@ -329,6 +326,16 @@ golangci-lint: $(GOLANGCI_LINT) ## Download golangci-lint locally if necessary.
329326
$(GOLANGCI_LINT): $(LOCALBIN)
330327
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/HEAD/install.sh | sh -s $(GOLANGCI_LINT_VERSION)
331328

329+
.PHONY: adc
330+
adc: $(ADC_BIN) ## Download adc locally if necessary.
331+
$(ADC_BIN):
332+
ifeq ($(ADC_VERSION),dev)
333+
@echo "ADC_VERSION=dev, skip download"
334+
else
335+
curl -sSfL https://github.com/api7/adc/releases/download/v${ADC_VERSION}/adc_${ADC_VERSION}_${GOOS}_${GOARCH}.tar.gz \
336+
| tar -xz -C $(LOCALBIN)
337+
endif
338+
332339
gofmt: ## Apply go fmt
333340
@gofmt -w -r 'interface{} -> any' .
334341
@gofmt -w -r 'FIt -> It' test

test/e2e/scaffold/adc.go

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import (
2323
"errors"
2424
"os"
2525
"os/exec"
26+
"strings"
2627
"time"
2728

2829
"github.com/api7/gopkg/pkg/log"
@@ -33,6 +34,20 @@ import (
3334
"github.com/apache/apisix-ingress-controller/internal/adc/translator"
3435
)
3536

37+
var (
38+
adcExec = "./bin/adc"
39+
adcArgs []string
40+
)
41+
42+
func init() {
43+
adc := os.Getenv("ADC_BIN")
44+
if adc != "" && strings.Contains(adc, "node") {
45+
parts := strings.Fields(adc)
46+
adcExec = parts[0]
47+
adcArgs = parts[1:]
48+
}
49+
}
50+
3651
// DataplaneResource defines the interface for accessing dataplane resources
3752
type DataplaneResource interface {
3853
Route() RouteResource
@@ -124,7 +139,7 @@ func (a *adcDataplaneResource) dumpResources(ctx context.Context) (*translator.T
124139
_ = os.Remove(tempFile.Name())
125140
}()
126141

127-
args := []string{"dump", "-o", tempFile.Name()}
142+
args := append(adcArgs, []string{"dump", "-o", tempFile.Name()}...)
128143
if !a.tlsVerify {
129144
args = append(args, "--tls-skip-verify")
130145
}
@@ -137,7 +152,7 @@ func (a *adcDataplaneResource) dumpResources(ctx context.Context) (*translator.T
137152
}
138153

139154
var stdout, stderr bytes.Buffer
140-
cmd := exec.CommandContext(ctxWithTimeout, "adc", args...)
155+
cmd := exec.CommandContext(ctxWithTimeout, adcExec, args...)
141156
cmd.Stdout = &stdout
142157
cmd.Stderr = &stderr
143158
cmd.Env = append(cmd.Env, os.Environ()...)

0 commit comments

Comments
 (0)