@@ -4,17 +4,6 @@ export PATH := ./build/scripts:$(PATH)
44
55image_manifest_file = build/docker/build_image_manifest
66
7- # We use git object hashes for determining the input files used for any given build image
8- # E.g. given `public.ecr.aws/eksctl/eksctl-build:d94225a6dbb6dfab6dd185442ae554432f9365dc` one can
9- # run `git show d94225a6dbb6dfab6dd185442ae554432f9365dc` to get contents of `.build_image_manifest`,
10- # and `git show <hash>` for each of the hashes in the manifest to determine contents of each of the
11- # files used in `$(build_image_input)` at the time.
12- build_image_tag_file = build/docker/image_tag
13- build_image_tag = $(shell cat $(build_image_tag_file))
14-
15- build_image = public.ecr.aws/eksctl/eksctl-build
16- build_image_name = $(build_image):$(build_image_tag)
17-
187eksctl_image = public.ecr.aws/eksctl/eksctl
198eksctl_image_name = "$(eksctl_image):$${EKSCTL_IMAGE_VERSION}"
209
@@ -33,55 +22,12 @@ endif
3322authenticate-ecr-for-docker: ## Get ECR public registry credentials with AWS credentials
3423 aws ecr-public get-login-password --region us-east-1 | docker login --username AWS --password-stdin public.ecr.aws
3524
36- .PHONY: update-build-image-tag
37- update-build-image-tag: ## Update the build image tag as referenced across the repo
38- build-image-manifest.sh > $(image_manifest_file)
39- git hash-object $(image_manifest_file) > $(build_image_tag_file)
40- sed $(sedi) -e "1s|\(BUILD_IMAGE=\).*|\1$(build_image):$$(cat $(build_image_tag_file))|" Dockerfile
41- find .github/workflows -type f | xargs sed $(sedi) -e "s|\($(build_image):\).*|\1$$(cat $(build_image_tag_file))|"
42-
43- .PHONY: check-build-image-manifest-up-to-date
44- check-build-image-manifest-up-to-date: update-build-image-tag ## Update build image manifest and commits the changes
45- git diff --quiet -- $(image_manifest_file) \
46- || (git --no-pager diff $(image_manifest_file); echo "HINT: to fix this, run 'make -f Makefile.docker update-build-image-tag' then 'commit-new-image-tag'"; exit 1)
47-
48- .PHONY: commit-new-image-tag
49- commit-new-image-tag: ## Update build image manifest and commits the changes
50- git add -u
51- git commit --message 'Update build image manifest, tag file and workflows'
52- @echo "Remember to run \"Publish ECR eksctl-build image\" GitHub workflow after merging these image tag changes"
53-
54- .PHONY: build-image
55- build-image: check-build-image-manifest-up-to-date ## Build the build image that has all of external dependencies
56- -docker pull $(build_image_name)
57- cp .requirements build/scripts/install-build-deps.sh go.mod go.sum build/docker/
58- $(docker_build) \
59- --cache-from=$(build_image_name) \
60- --tag=$(build_image_name) \
61- build/docker/
62-
63- .PHONY: push-build-image
64- push-build-image: authenticate-ecr-for-docker build-image ## Push the build image to the ECR public registry
65- docker push $(build_image_name)
66- @echo "Remember to commit the image_tag and build_image_manifest files"
67-
6825.PHONY: eksctl-image
6926eksctl-image: ## Build the eksctl image that has release artefacts and no build dependencies
70- docker pull $(build_image_name)
7127 $(docker_build) \
72- --cache-from=$(build_image_name) \
7328 --tag=$(eksctl_image_name) \
74- --build-arg=BUILD_IMAGE=$(build_image_name) \
7529 $(git_toplevel)
7630
7731.PHONY: eksctl-image
7832push-eksctl-image: eksctl-image ## Push the eksctl image to the ECR public registry
7933 docker push $(eksctl_image_name)
80-
81- .PHONY: build-test
82- build-test: ## Run targets from Makefile using the build image
83- time docker run \
84- --tty \
85- --rm \
86- --volume=$(git_toplevel):/src \
87- $(build_image_name) make $@
0 commit comments