Skip to content

Commit

Permalink
standardize batch builds for archd images
Browse files Browse the repository at this point in the history
  • Loading branch information
jaxesn committed Nov 22, 2023
1 parent ca5476b commit b9f84ae
Show file tree
Hide file tree
Showing 15 changed files with 135 additions and 122 deletions.
10 changes: 8 additions & 2 deletions Common.mk
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ else
endif
EXCLUDE_FROM_STAGING_BUILDSPEC?=false
EXCLUDE_FROM_CHECKSUMS_BUILDSPEC?=false
DO_NOT_EXCLUDE_FROM_BUILDSPEC=false
BUILDSPECS?=buildspec.yml
CHECKSUMS_BUILDSPECS?=buildspecs/checksums-buildspec.yml
BUILDSPEC_VARS_KEYS?=
Expand Down Expand Up @@ -102,7 +103,7 @@ IS_RELEASE_BRANCH_BUILD=$(filter true,$(HAS_RELEASE_BRANCHES))
UNRELEASE_BRANCH_BINARY_TARGETS=binaries attribution checksums
IS_UNRELEASE_BRANCH_TARGET=$(and $(filter false,$(BINARIES_ARE_RELEASE_BRANCHED)),$(filter $(UNRELEASE_BRANCH_BINARY_TARGETS) $(foreach target,$(UNRELEASE_BRANCH_BINARY_TARGETS),run-$(target)-in-docker run-in-docker/$(target)),$(MAKECMDGOALS)))
TARGETS_ALLOWED_WITH_NO_RELEASE_BRANCH?=
TARGETS_ALLOWED_WITH_NO_RELEASE_BRANCH+=build release clean clean-extra clean-go-cache help start-docker-builder stop-docker-builder create-ecr-repos all-attributions all-checksums all-attributions-checksums update-patch-numbers check-for-release-branch-skip run-buildkit-and-registry
TARGETS_ALLOWED_WITH_NO_RELEASE_BRANCH+=build release clean clean-extra clean-go-cache help start-docker-builder stop-docker-builder create-ecr-repos all-attributions all-checksums all-attributions-checksums update-patch-numbers check-for-release-branch-skip run-buildkit-and-registry $(if $(filter true, $(HAS_HELM_CHART)),,helm/push)
MAKECMDGOALS_WITHOUT_VAR_VALUE=$(foreach t,$(MAKECMDGOALS),$(if $(findstring var-value-,$(t)),,$(t)))
ifneq ($(and $(IS_RELEASE_BRANCH_BUILD),$(or $(RELEASE_BRANCH),$(IS_UNRELEASE_BRANCH_TARGET))),)
RELEASE_BRANCH_SUFFIX=$(if $(filter true,$(BINARIES_ARE_RELEASE_BRANCHED)),/$(RELEASE_BRANCH),)
Expand Down Expand Up @@ -828,6 +829,11 @@ clean-job-caches: $(and $(findstring presubmit,$(JOB_TYPE)),$(filter true,$(PRUN
%-useradd/images/export: | $$(ENSURE_PREREQ) $$(ENABLE_LOGGING)
@mkdir -p $(IMAGE_OUTPUT_DIR) && $(BUILDCTL)

PHONY: combine-images
combine-images: IMAGE_BUILD_ARGS=IMAGE
combine-images: DOCKERFILE_FOLDER=$(BUILD_LIB)/docker/linux/combine
combine-images: images

## Helm Targets
.PHONY: helm/pull
helm/pull: | $$(ENABLE_LOGGING)
Expand Down Expand Up @@ -857,7 +863,7 @@ helm/build: $(foreach chart,$(HELM_CHART_NAMES),$(chart)/helm/build)

# Build helm chart and push to registry defined in IMAGE_REPO.
.PHONY: helm/push
helm/push: $(foreach chart,$(HELM_CHART_NAMES),$(chart)/helm/push)
helm/push: $(if $(filter true,$(HAS_HELM_CHART)),$(foreach chart,$(HELM_CHART_NAMES),$(chart)/helm/push),)

#@ Fetch Binary Targets
.PHONY: handle-dependencies
Expand Down
1 change: 1 addition & 0 deletions EKS_DISTRO_MINIMAL_BASE_NSENTER_TAG_FILE
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2023-10-20-1697820183.2
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ generate-project-list: | ensure-locale

.PHONY: generate-staging-buildspec
generate-staging-buildspec: export BINARY_PLATFORMS=linux/amd64 linux/arm64
generate-staging-buildspec: export IMAGE_PLATFORMS=linux/amd64 linux/arm64
generate-staging-buildspec: | ensure-locale
build/lib/generate_staging_buildspec.sh $(BASE_DIRECTORY) "$(ALL_PROJECTS)" "$(BASE_DIRECTORY)/release/staging-build.yml" "$(BASE_DIRECTORY)/buildspec.yml"
build/lib/generate_staging_buildspec.sh $(BASE_DIRECTORY) "$(ALL_PROJECTS)" "$(BASE_DIRECTORY)/release/checksums-build.yml" "$(BASE_DIRECTORY)/buildspecs/checksums-buildspec.yml" true EXCLUDE_FROM_CHECKSUMS_BUILDSPEC CHECKSUMS_BUILDSPECS false buildspecs/checksums-pr-buildspec.yml
Expand All @@ -199,7 +200,9 @@ generate-staging-buildspec: | ensure-locale
build/lib/generate_staging_buildspec.sh $(BASE_DIRECTORY) "containerd_containerd" "$(BASE_DIRECTORY)/projects/containerd/containerd/buildspecs/batch-build.yml" "$(BASE_DIRECTORY)/buildspec.yml" true
build/lib/generate_staging_buildspec.sh $(BASE_DIRECTORY) "opencontainers_runc" "$(BASE_DIRECTORY)/projects/opencontainers/runc/buildspecs/batch-build.yml" "$(BASE_DIRECTORY)/buildspec.yml" true
build/lib/generate_staging_buildspec.sh $(BASE_DIRECTORY) "torvalds_linux" "$(BASE_DIRECTORY)/projects/torvalds/linux/buildspecs/batch-build.yml" "$(BASE_DIRECTORY)/buildspec.yml" true
build/lib/generate_staging_buildspec.sh $(BASE_DIRECTORY) "aws_upgrader" "$(BASE_DIRECTORY)/projects/aws/upgrader/buildspecs/batch-build.yml" "$(BASE_DIRECTORY)/buildspec.yml" true
build/lib/generate_staging_buildspec.sh $(BASE_DIRECTORY) "emissary-ingress_emissary" "$(BASE_DIRECTORY)/projects/emissary-ingress/emissary/buildspecs/batch-build.yml" "$(BASE_DIRECTORY)/buildspec.yml" true "DO_NOT_EXCLUDE_FROM_BUILDSPEC"
build/lib/generate_staging_buildspec.sh $(BASE_DIRECTORY) "goharbor_harbor" "$(BASE_DIRECTORY)/projects/goharbor/harbor/buildspecs/batch-build.yml" "$(BASE_DIRECTORY)/buildspec.yml" true "DO_NOT_EXCLUDE_FROM_BUILDSPEC"
build/lib/generate_staging_buildspec.sh $(BASE_DIRECTORY) "aws_upgrader" "$(BASE_DIRECTORY)/projects/aws/upgrader/buildspecs/batch-build.yml" "$(BASE_DIRECTORY)/buildspec.yml" true "DO_NOT_EXCLUDE_FROM_BUILDSPEC"

.PHONY: generate
generate: generate-project-list generate-staging-buildspec
Expand Down
File renamed without changes.
18 changes: 14 additions & 4 deletions build/lib/generate_staging_buildspec.sh
Original file line number Diff line number Diff line change
Expand Up @@ -184,18 +184,28 @@ for project in "${PROJECTS[@]}"; do

# If building on one binary platform assume we want to run on a specific arch instance
ARCH_TYPE="\"type\":\"$BUILDSPEC_PLATFORM\",\"compute-type\":\"$BUILDSPEC_COMPUTE_TYPE\","
if [ "${KEYS[0]}" = "BINARY_PLATFORMS" ]; then
if [ "${KEYS[0]}" = "BINARY_PLATFORMS" ] || [ "${KEYS[0]}" = "IMAGE_PLATFORMS" ]; then
if [ "${val1}" = "linux/amd64" ]; then
ARCH_TYPE="\"type\":\"LINUX_CONTAINER\",\"compute-type\":\"BUILD_GENERAL1_SMALL\","
ARCH_TYPE="\"type\":\"LINUX_CONTAINER\",\"compute-type\":\"$BUILDSPEC_COMPUTE_TYPE\","
else
ARCH_TYPE="\"type\":\"ARM_CONTAINER\",\"compute-type\":\"BUILD_GENERAL1_SMALL\","
ARCH_TYPE="\"type\":\"ARM_CONTAINER\",\"compute-type\":\"$BUILDSPEC_COMPUTE_TYPE\","
fi
fi

EXTRA_VARS=""
if [ "${KEYS[0]}" = "IMAGE_PLATFORMS" ]; then
EXTRA_VARS+=",\"BINARY_PLATFORMS\":\"${val1}\",\"IMAGE_TAG_SUFFIX\":\"-${val1#linux/}\""
HAS_HELM_CHART=$(make_var $PROJECT_PATH HAS_HELM_CHART)
if [ "${HAS_HELM_CHART}" = "true" ]; then
EXTRA_VARS+=",\"HAS_HELM_CHART\":\"false\""
fi
fi

ALL_PROJECT_IDS+="\"$IDENTIFIER\","
yq eval -i -P \
".batch.build-graph += [{\"identifier\":\"$IDENTIFIER\",$buildspec_field$DEPEND_ON\"env\":{$ARCH_TYPE\"variables\":{\"PROJECT_PATH\": \"projects/$org/$repo\"$CLONE_URL,\"${KEYS[0]}\":\"$val1\"}}}]" \
".batch.build-graph += [{\"identifier\":\"$IDENTIFIER\",$buildspec_field$DEPEND_ON\"env\":{$ARCH_TYPE\"variables\":{\"PROJECT_PATH\": \"projects/$org/$repo\"$CLONE_URL,\"${KEYS[0]}\":\"$val1\"$EXTRA_VARS}}}]" \
$STAGING_BUILDSPEC_FILE

done
else
VALUES_1=$(make_var $PROJECT_PATH ${VARS[0]})
Expand Down
17 changes: 17 additions & 0 deletions buildspecs/combine-images.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
version: 0.2

env:
variables:
RELEASE_TARGETS: "combine-images helm/push"
BINARY_TARGETS: ""
LICENSES_TARGETS_FOR_PREREQ: ""
HANDLE_DEPENDENCIES_TARGET: ""

phases:
pre_build:
commands:
- ./build/lib/setup.sh

build:
commands:
- if $(make check-project-path-exists); then make release -C $PROJECT_PATH; fi
14 changes: 10 additions & 4 deletions projects/aws/upgrader/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,21 @@ GIT_TAG=v$(RELEASE_BRANCH)-$(shell yq e ".releases[] | select(.branch==\"${RELEA

HAS_RELEASE_BRANCHES=true

BUILDSPEC_VARS_KEYS=RELEASE_BRANCH
BUILDSPEC_VARS_VALUES=SUPPORTED_K8S_VERSIONS
BUILDSPEC_DEPENDS_ON_OVERRIDE=containerd_containerd_linux_amd64 containerd_containerd_linux_arm64 kubernetes_sigs_cri_tools
EXCLUDE_FROM_CHECKSUMS_BUILDSPEC=true
# for the staging buildspec generation
BUILDSPEC_DEPENDS_ON_OVERRIDE=containerd_containerd_linux_amd64 containerd_containerd_linux_arm64 kubernetes_sigs_cri_tools

BUILDSPECS=buildspec.yml buildspecs/combine-images.yml
BUILDSPEC_1_COMPUTE_TYPE=BUILD_GENERAL1_LARGE
BUILDSPEC_1_VARS_KEYS=IMAGE_PLATFORMS
BUILDSPEC_1_VARS_VALUES=IMAGE_PLATFORMS
BUILDSPEC_1_ARCH_TYPES=LINUX_CONTAINER ARM_CONTAINER
BUILDSPEC_2_DEPENDS_ON_OVERRIDE=aws_upgrader_linux_amd64 aws_upgrader_linux_arm64

REPO_NO_CLONE=true
HAS_LICENSES=false

BASE_IMAGE_NAME=eks-distro-minimal-base-glibc
BASE_IMAGE_NAME=eks-distro-minimal-base-nsenter
IMAGE_NAMES=upgrader

PROJECT_DEPENDENCIES=eksd/kubernetes/client eksd/kubernetes/server eksd/cni-plugins eksa/containerd/containerd eksa/kubernetes-sigs/cri-tools
Expand Down
35 changes: 13 additions & 22 deletions projects/aws/upgrader/buildspecs/batch-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,36 +17,27 @@
batch:
fast-fail: true
build-graph:
- identifier: aws_upgrader_1_24
- identifier: aws_upgrader_linux_amd64
env:
type: ARM_CONTAINER
compute-type: BUILD_GENERAL1_SMALL
variables:
RELEASE_BRANCH: 1-24
- identifier: aws_upgrader_1_25
env:
type: ARM_CONTAINER
compute-type: BUILD_GENERAL1_SMALL
type: LINUX_CONTAINER
compute-type: BUILD_GENERAL1_LARGE
variables:
RELEASE_BRANCH: 1-25
- identifier: aws_upgrader_1_26
IMAGE_PLATFORMS: linux/amd64
BINARY_PLATFORMS: linux/amd64
IMAGE_TAG_SUFFIX: -amd64
- identifier: aws_upgrader_linux_arm64
env:
type: ARM_CONTAINER
compute-type: BUILD_GENERAL1_SMALL
variables:
RELEASE_BRANCH: 1-26
- identifier: aws_upgrader_1_27
env:
type: ARM_CONTAINER
compute-type: BUILD_GENERAL1_SMALL
compute-type: BUILD_GENERAL1_LARGE
variables:
RELEASE_BRANCH: 1-27
- identifier: aws_upgrader_1_28
IMAGE_PLATFORMS: linux/arm64
BINARY_PLATFORMS: linux/arm64
IMAGE_TAG_SUFFIX: -arm64
- identifier: aws_upgrader
buildspec: buildspecs/combine-images.yml
env:
type: ARM_CONTAINER
compute-type: BUILD_GENERAL1_SMALL
variables:
RELEASE_BRANCH: 1-28
version: 0.2
phases:
pre_build:
Expand Down
3 changes: 1 addition & 2 deletions projects/aws/upgrader/docker/linux/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ ARG BUILDER_IMAGE
FROM $BUILDER_IMAGE as builder

RUN set -x && \
install_binary /usr/bin/nsenter \
/usr/bin/cp && \
install_binary /usr/bin/cp && \
cleanup "deps"

FROM $BASE_IMAGE
Expand Down
13 changes: 8 additions & 5 deletions projects/emissary-ingress/emissary/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,14 @@ REPO=emissary
REPO_OWNER=emissary-ingress

EXCLUDE_FROM_STAGING_BUILDSPEC=true

BUILDSPECS=buildspec.yml buildspecs/combine-images.yml
BUILDSPEC_1_COMPUTE_TYPE=BUILD_GENERAL1_LARGE
BUILDSPEC_1_VARS_KEYS=IMAGE_PLATFORMS
BUILDSPEC_1_VARS_VALUES=IMAGE_PLATFORMS
BUILDSPEC_1_ARCH_TYPES=LINUX_CONTAINER ARM_CONTAINER
BUILDSPEC_2_DEPENDS_ON_OVERRIDE=emissary_ingress_emissary_linux_amd64 emissary_ingress_emissary_linux_arm64

SKIP_ON_RELEASE_BRANCH=true

BINARY_TARGET_FILES=busyambassador capabilities_wrapper example-envoy-metrics-sink k8sregistryctl kat-client kat-server
Expand All @@ -33,7 +41,6 @@ AMBASSADOR_VERSION_TARGET=$(REPO)/python/ambassador.version
include $(BASE_DIRECTORY)/Common.mk


combine/images/push: IMAGE_BUILD_ARGS=IMAGE
emissary-ingress/emissary/helm/%: PACKAGE_DEPENDENCIES=emissary-crds

emissary/crds/helm/%: HELM_DIRECTORY=charts/crds
Expand All @@ -56,10 +63,6 @@ $(AMBASSADOR_VERSION_TARGET): export GOPATH=/var
$(AMBASSADOR_VERSION_TARGET): | $$(ENABLE_DOCKER)
@$(MAKE) -C $(REPO) python/ambassador.version

PHONY: combine-images
combine-images: IMAGE_BUILD_ARGS=IMAGE
combine-images: DOCKERFILE_FOLDER=./docker/linux/combine
combine-images: images

########### DO NOT EDIT #############################
# To update call: make add-generated-help-block
Expand Down
38 changes: 19 additions & 19 deletions projects/emissary-ingress/emissary/buildspecs/batch-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,39 +12,39 @@
# See the License for the specific language governing permissions and
# limitations under the License.

# This file was generated by running `make generate`. DO NOT EDIT

batch:
fast-fail: true
build-graph:
- identifier: emissary_ingress_emissary_amd64
buildspec: buildspec.yml
- identifier: emissary_ingress_emissary_linux_amd64
env:
type: LINUX_CONTAINER
compute-type: BUILD_GENERAL1_LARGE
variables:
IMAGE_TAG_SUFFIX: "-amd64"
IMAGE_PLATFORMS: linux/amd64
HAS_HELM_CHART: ""
- identifier: emissary_ingress_emissary_arm64
buildspec: buildspec.yml
IMAGE_PLATFORMS: linux/amd64
BINARY_PLATFORMS: linux/amd64
IMAGE_TAG_SUFFIX: -amd64
HAS_HELM_CHART: "false"
- identifier: emissary_ingress_emissary_linux_arm64
env:
type: ARM_CONTAINER
compute-type: BUILD_GENERAL1_LARGE
variables:
IMAGE_TAG_SUFFIX: "-arm64"
IMAGE_PLATFORMS: linux/arm64
BINARY_PLATFORMS: linux/arm64
HAS_S3_ARTIFACTS: ""
HAS_HELM_CHART: ""
IMAGE_TAG_SUFFIX: -arm64
HAS_HELM_CHART: "false"
- identifier: emissary_ingress_emissary
buildspec: buildspecs/images.yml
depend-on:
- emissary_ingress_emissary_amd64
- emissary_ingress_emissary_arm64
buildspec: buildspecs/combine-images.yml
env:
type: ARM_CONTAINER
compute-type: BUILD_GENERAL1_SMALL
variables:
RELEASE_TARGETS: "combine-images helm/push"
BINARY_TARGETS: ""
LICENSES_TARGETS_FOR_PREREQ: ""
HANDLE_DEPENDENCIES_TARGET: ""
version: 0.2
phases:
pre_build:
commands:
- ./build/lib/setup.sh
build:
commands:
- if $(make check-project-path-exists) && make check-for-release-branch-skip -C $PROJECT_PATH; then make release -C $PROJECT_PATH; fi
14 changes: 6 additions & 8 deletions projects/goharbor/harbor/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,12 @@ HELM_IMAGE_LIST=harbor/harbor-core harbor/harbor-db harbor/harbor-log harbor/har
HELM_CHART_NAMES=harbor/$(HELM_SOURCE_REPOSITORY)

EXCLUDE_FROM_STAGING_BUILDSPEC=true
BUILDSPEC_COMPUTE_TYPE=BUILD_GENERAL1_LARGE
BUILDSPECS=buildspec.yml buildspecs/combine-images.yml
BUILDSPEC_1_COMPUTE_TYPE=BUILD_GENERAL1_LARGE
BUILDSPEC_1_VARS_KEYS=IMAGE_PLATFORMS
BUILDSPEC_1_VARS_VALUES=IMAGE_PLATFORMS
BUILDSPEC_1_ARCH_TYPES=LINUX_CONTAINER ARM_CONTAINER
BUILDSPEC_2_DEPENDS_ON_OVERRIDE=goharbor_harbor_linux_amd64 goharbor_harbor_linux_arm64

SKIP_ON_RELEASE_BRANCH=true

Expand All @@ -75,7 +80,6 @@ include $(BASE_DIRECTORY)/Common.mk
harbor-nginx/images/%: BASE_IMAGE_NAME=eks-distro-minimal-base-nginx
harbor-portal/images/%: BASE_IMAGE_NAME=eks-distro-minimal-base-nginx
harbor-redis/images/%: BASE_IMAGE_NAME=eks-distro-minimal-base-glibc
combine/images/push: IMAGE_BUILD_ARGS=IMAGE

$(GO_MOD_DOWNLOAD_TARGETS): $(OUTPUT_DIR)/$(REPO)

Expand Down Expand Up @@ -149,12 +153,6 @@ $(FIX_LICENSES_XEIPUUV_TARGET): | $(GO_MOD_DOWNLOAD_TARGETS)
$$dest; \
done;

PHONY: combine-images
combine-images: IMAGE_BUILD_ARGS=IMAGE
combine-images: DOCKERFILE_FOLDER=./docker/linux/combine
combine-images: images


########### DO NOT EDIT #############################
# To update call: make add-generated-help-block
# This is added to help document dynamic targets and support shell autocompletion
Expand Down
38 changes: 19 additions & 19 deletions projects/goharbor/harbor/buildspecs/batch-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,39 +12,39 @@
# See the License for the specific language governing permissions and
# limitations under the License.

# This file was generated by running `make generate`. DO NOT EDIT

batch:
fast-fail: true
build-graph:
- identifier: goharbor_harbor_amd64
buildspec: buildspec.yml
- identifier: goharbor_harbor_linux_amd64
env:
type: LINUX_CONTAINER
compute-type: BUILD_GENERAL1_LARGE
variables:
IMAGE_TAG_SUFFIX: "-amd64"
IMAGE_PLATFORMS: linux/amd64
HAS_HELM_CHART: ""
- identifier: goharbor_harbor_arm64
buildspec: buildspec.yml
IMAGE_PLATFORMS: linux/amd64
BINARY_PLATFORMS: linux/amd64
IMAGE_TAG_SUFFIX: -amd64
HAS_HELM_CHART: "false"
- identifier: goharbor_harbor_linux_arm64
env:
type: ARM_CONTAINER
compute-type: BUILD_GENERAL1_LARGE
variables:
IMAGE_TAG_SUFFIX: "-arm64"
IMAGE_PLATFORMS: linux/arm64
BINARY_PLATFORMS: linux/arm64
HAS_S3_ARTIFACTS: ""
HAS_HELM_CHART: ""
IMAGE_TAG_SUFFIX: -arm64
HAS_HELM_CHART: "false"
- identifier: goharbor_harbor
buildspec: buildspecs/images.yml
depend-on:
- goharbor_harbor_amd64
- goharbor_harbor_arm64
buildspec: buildspecs/combine-images.yml
env:
type: ARM_CONTAINER
compute-type: BUILD_GENERAL1_SMALL
variables:
RELEASE_TARGETS: "combine-images helm/push"
BINARY_TARGETS: ""
LICENSES_TARGETS_FOR_PREREQ: ""
HANDLE_DEPENDENCIES_TARGET: ""
version: 0.2
phases:
pre_build:
commands:
- ./build/lib/setup.sh
build:
commands:
- if $(make check-project-path-exists) && make check-for-release-branch-skip -C $PROJECT_PATH; then make release -C $PROJECT_PATH; fi
2 changes: 0 additions & 2 deletions projects/goharbor/harbor/docker/linux/combine/Dockerfile

This file was deleted.

Loading

0 comments on commit b9f84ae

Please sign in to comment.