Skip to content

Commit 53bb7f8

Browse files
author
Sheyla Trudo
committed
fixup! Separate Build Changes
1 parent d0b7de3 commit 53bb7f8

File tree

2 files changed

+94
-28
lines changed

2 files changed

+94
-28
lines changed

.pipelines/containers/container-template.steps.yaml

Lines changed: 31 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,36 @@ parameters:
44
os: ""
55

66
steps:
7-
- task: AzureCLI@2
8-
displayName: "Image Build"
7+
- bash: |
8+
set -e
9+
10+
IMAGE_NAME_AND_TAG=$(make "$MAKE_IMG_NAME_AND_TAG")
11+
echo >&2 "##vso[task.setvariable variable=IMAGE_NAME_AND_TAG_${VAR_ID};]$IMAGE_NAME_AND_TAG"
12+
13+
DOCKERFILE_PATH=$(make "$MAKE_DOCKERFILE_PATH")
14+
echo >&2 "##vso[task.setvariable variable=DOCKERFILE_PATH_${VAR_ID};]$DOCKERFILE_PATH"
15+
16+
EXTRA_BUILD_ARGS=$(make "$MAKE_EXTRA_BUILD_ARGS")
17+
echo >&2 "##vso[task.setvariable variable=EXTRA_BUILD_ARGS_${VAR_ID};]$EXTRA_BUILD_ARGS"
18+
displayName: "Get Image Name"
19+
env:
20+
VAR_ID: ${{ parameters.name }}
21+
MAKE_IMG_NAME_AND_TAG: ${{ parameters.name }}-image-name-and-tag
22+
MAKE_DOCKERFILE_PATH: ${{ parameters.name }}-image-dockerfile-path
23+
MAKE_EXTRA_BUILD_ARGS: ${{ parameters.name }}-image-build-args
24+
25+
- task: 1ES.BuildContainerImage@1
926
retryCountOnTaskFailure: 3
1027
inputs:
11-
azureSubscription: $(ACR_ARM_SERVICE_CONNECTION)
12-
addSpnToEnvironment: True
13-
scriptLocation: "inlineScript"
14-
scriptType: "bash"
15-
inlineScript: |
16-
set -e
17-
make "$MAKE_CMD"
18-
env:
19-
OS: ${{ parameters.os }}
20-
ARCH: ${{ parameters.arch }}
21-
MAKE_CMD: ${{ parameters.name }}-image
22-
${{ if eq(parameters.os, 'windows') }}:
23-
BUILDX_ACTION: '--push'
28+
image: $(IMAGE_NAME_AND_TAG_${{ parameters.name }})
29+
dockerfile: $(DOCKERFILE_PATH_${{ parameters.name }})
30+
buildArguments: TARGET=${{ parameters.os }} OS=${{ parameters.os }} PLATFORM=${{ parameters.os }} ARCH=${{ parameters.arch }} $(EXTRA_BUILD_ARGS_${{ parameters.name }})
31+
enableNetwork: true # Optional. Default: false
32+
enablePull: false # Optional. Default: true
33+
enableCache: true # Optional. Default: false
34+
useBuildKit: true
35+
36+
- task: 1ES.PushContainerImage@1
37+
condition: ${{ eq(parameters.os, 'windows') }}
38+
inputs:
39+
image: $(IMAGE_NAME_AND_TAG_${{ parameters.name }})

Makefile

Lines changed: 63 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -337,11 +337,20 @@ acncli-image-name: # util target to print the CNI manager image name.
337337
acncli-image-name-and-tag: # util target to print the CNI manager image name and tag.
338338
@echo $(IMAGE_REGISTRY)/$(ACNCLI_IMAGE):$(ACNCLI_PLATFORM_TAG)
339339

340-
acncli-image: ## build cni-manager container image.
340+
acncli-dockerfile-path:
341+
$(eval DOCKERFILE_PATH := $(ACNCLI_DIR)/Dockerfile)
342+
@echo "$(DOCKERFILE_PATH)"
343+
344+
acncli-build-args:
345+
$(eval DOCKER_BUILD_ARGS := ;)
346+
@echo $(DOCKER_BUILD_ARGS)
347+
348+
acncli-image: acncli-dockerfile-path acncli-build-args ## build cni-manager container image.
341349
$(MAKE) container \
342-
DOCKERFILE=tools/acncli/Dockerfile \
350+
DOCKERFILE=$(DOCKERFILE_PATH) \
343351
IMAGE=$(ACNCLI_IMAGE) \
344-
TAG=$(ACNCLI_PLATFORM_TAG)
352+
TAG=$(ACNCLI_PLATFORM_TAG) \
353+
$(DOCKER_BUILD_ARGS)
345354

346355
acncli-image-push: ## push cni-manager container image.
347356
$(MAKE) container-push \
@@ -362,15 +371,24 @@ azure-ipam-image-name: # util target to print the azure-ipam image name.
362371
azure-ipam-image-name-and-tag: # util target to print the azure-ipam image name and tag.
363372
@echo $(IMAGE_REGISTRY)/$(AZURE_IPAM_IMAGE):$(AZURE_IPAM_PLATFORM_TAG)
364373

374+
azure-ipam-dockerfile-path:
375+
$(eval DOCKERFILE_PATH := $(AZURE_IPAM_DIR)/Dockerfile)
376+
@echo "$(DOCKERFILE_PATH)"
377+
378+
azure-ipam-build-args:
379+
$(eval DOCKER_BUILD_ARGS := ;)
380+
@echo $(DOCKER_BUILD_ARGS)
381+
365382
azure-ipam-image: ## build azure-ipam container image.
366383
$(MAKE) container \
367-
DOCKERFILE=azure-ipam/Dockerfile \
384+
DOCKERFILE=$(DOCKERFILE_PATH) \
368385
IMAGE=$(AZURE_IPAM_IMAGE) \
369386
PLATFORM=$(PLATFORM) \
370387
TAG=$(AZURE_IPAM_PLATFORM_TAG) \
371388
TARGET=$(OS) \
372389
OS=$(OS) \
373-
ARCH=$(ARCH)
390+
ARCH=$(ARCH) \
391+
$(DOCKER_BUILD_ARGS)
374392

375393
azure-ipam-image-push: ## push azure-ipam container image.
376394
$(MAKE) container-push \
@@ -390,11 +408,19 @@ ipv6-hp-bpf-image-name: # util target to print the ipv6-hp-bpf image name.
390408
ipv6-hp-bpf-image-name-and-tag: # util target to print the ipv6-hp-bpf image name and tag.
391409
@echo $(IMAGE_REGISTRY)/$(IPV6_HP_BPF_IMAGE):$(IPV6_HP_BPF_IMAGE_PLATFORM_TAG)
392410

411+
ipv6-hp-bpf-dockerfile-path:
412+
$(eval DOCKERFILE_PATH := $(IPV6_HP_BPF_DIR)/$(OS).Dockerfile)
413+
@echo "$(DOCKERFILE_PATH)"
414+
415+
ipv6-hp-bpf-build-args:
416+
$(eval DOCKER_BUILD_ARGS := '--build-arg OS=$(OS) --build-arg ARCH=$(ARCH) --build-arg DEBUG=$(DEBUG)')
417+
@echo $(DOCKER_BUILD_ARGS)
418+
393419
ipv6-hp-bpf-image: ## build ipv6-hp-bpf container image.
394420
$(MAKE) container \
395-
DOCKERFILE=bpf-prog/ipv6-hp-bpf/$(OS).Dockerfile \
421+
DOCKERFILE=$(DOCKERFILE_PATH) \
396422
IMAGE=$(IPV6_HP_BPF_IMAGE) \
397-
EXTRA_BUILD_ARGS='--build-arg OS=$(OS) --build-arg ARCH=$(ARCH) --build-arg DEBUG=$(DEBUG)'\
423+
EXTRA_BUILD_ARGS='$(DOCKER_BUILD_ARGS)'\
398424
PLATFORM=$(PLATFORM) \
399425
TAG=$(IPV6_HP_BPF_IMAGE_PLATFORM_TAG) \
400426
TARGET=$(OS) \
@@ -419,16 +445,24 @@ cni-image-name: # util target to print the cni image name.
419445
cni-image-name-and-tag: # util target to print the cni image name and tag.
420446
@echo $(IMAGE_REGISTRY)/$(CNI_IMAGE):$(CNI_PLATFORM_TAG)
421447

448+
cni-image-dockerfile-path:
449+
$(eval DOCKERFILE_PATH := $(CNI_BUILD_DIR)/Dockerfile)
450+
@echo "$(DOCKERFILE_PATH)"
451+
452+
cni-image-build-args:
453+
$(eval DOCKER_BUILD_ARGS='--build-arg CNI_AI_PATH=$(CNI_AI_PATH) --build-arg CNI_AI_ID=$(CNI_AI_ID)')
454+
@echo $(DOCKER_BUILD_ARGS)
455+
422456
cni-image: ## build cni container image.
423457
$(MAKE) container \
424-
DOCKERFILE=cni/Dockerfile \
458+
DOCKERFILE=$(DOCKERFILE_PATH) \
425459
IMAGE=$(CNI_IMAGE) \
426460
PLATFORM=$(PLATFORM) \
427461
TAG=$(CNI_PLATFORM_TAG) \
428462
TARGET=$(OS) \
429463
OS=$(OS) \
430464
ARCH=$(ARCH) \
431-
EXTRA_BUILD_ARGS='--build-arg CNI_AI_PATH=$(CNI_AI_PATH) --build-arg CNI_AI_ID=$(CNI_AI_ID)'
465+
EXTRA_BUILD_ARGS='$(DOCKER_BUILD_ARGS)'
432466

433467
cni-image-push: ## push cni container image.
434468
$(MAKE) container-push \
@@ -449,11 +483,19 @@ cns-image-name: # util target to print the CNS image name
449483
cns-image-name-and-tag: # util target to print the CNS image name and tag.
450484
@echo $(IMAGE_REGISTRY)/$(CNS_IMAGE):$(CNS_PLATFORM_TAG)
451485

486+
cns-image-dockerfile-path:
487+
$(eval DOCKERFILE_PATH := $(CNS_BUILD_DIR)/Dockerfile)
488+
@echo "$(DOCKERFILE_PATH)"
489+
490+
cns-image-build-args:
491+
$(eval DOCKER_BUILD_ARGS='--build-arg CNS_AI_PATH=$(CNS_AI_PATH) --build-arg CNS_AI_ID=$(CNS_AI_ID)')
492+
@echo $(DOCKER_BUILD_ARGS)
493+
452494
cns-image: ## build cns container image.
453495
$(MAKE) container \
454-
DOCKERFILE=cns/Dockerfile \
496+
DOCKERFILE=$(DOCKERFILE_PATH) \
455497
IMAGE=$(CNS_IMAGE) \
456-
EXTRA_BUILD_ARGS='--build-arg CNS_AI_PATH=$(CNS_AI_PATH) --build-arg CNS_AI_ID=$(CNS_AI_ID)' \
498+
EXTRA_BUILD_ARGS='$(DOCKER_BUILD_ARGS)' \
457499
PLATFORM=$(PLATFORM) \
458500
TAG=$(CNS_PLATFORM_TAG) \
459501
TARGET=$(OS) \
@@ -478,11 +520,19 @@ npm-image-name: # util target to print the NPM image name
478520
npm-image-name-and-tag: # util target to print the NPM image name and tag.
479521
@echo $(IMAGE_REGISTRY)/$(NPM_IMAGE):$(NPM_PLATFORM_TAG)
480522

523+
npm-image-dockerfile-path:
524+
$(eval DOCKERFILE_PATH := $(NPM_BUILD_DIR)/$(OS).Dockerfile)
525+
@echo "$(DOCKERFILE_PATH)"
526+
527+
npm-image-build-args:
528+
$(eval DOCKER_BUILD_ARGS='--build-arg NPM_AI_PATH=$(NPM_AI_PATH) --build-arg NPM_AI_ID=$(NPM_AI_ID)')
529+
@echo $(DOCKER_BUILD_ARGS)
530+
481531
npm-image: ## build the npm container image.
482532
$(MAKE) container-$(CONTAINER_BUILDER) \
483-
DOCKERFILE=npm/$(OS).Dockerfile \
533+
DOCKERFILE=$(DOCKERFILE_PATH) \
484534
IMAGE=$(NPM_IMAGE) \
485-
EXTRA_BUILD_ARGS='--build-arg NPM_AI_PATH=$(NPM_AI_PATH) --build-arg NPM_AI_ID=$(NPM_AI_ID)' \
535+
EXTRA_BUILD_ARGS='$(DOCKER_BUILD_ARGS)' \
486536
PLATFORM=$(PLATFORM) \
487537
TAG=$(NPM_PLATFORM_TAG) \
488538
TARGET=$(OS) \

0 commit comments

Comments
 (0)