-
Notifications
You must be signed in to change notification settings - Fork 193
Makefile: Fixes and improvements #1935
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Makefile
Outdated
| KOCACHE := $(PROJECT_BIN)/kocache | ||
| KO_TAGS := --tags $(IMAGE_TAG) --tags $(GIT_VERSION) --tags $(GIT_HASH) | ||
|
|
||
| $(KO_BIN): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note
Tasks like these will only run if the file in the make target doesn't exist. Allowig caching.
These can be force executed using make -B or by removing the file.
Makefile
Outdated
| ko: ## Build images using ko | ||
| $(create_kocache_path) | ||
| $(eval DIGEST := $(shell LDFLAGS="$(LDFLAGS)" GIT_HASH=$(GIT_HASH) GIT_VERSION=$(GIT_VERSION) \ | ||
| KOCACHE=$(KOCACHE_PATH) ko build --bare \ | ||
| --platform=all --tags $(IMAGE_TAG) --tags $(GIT_VERSION) --tags $(GIT_HASH) \ | ||
| chainguard.dev/apko)) | ||
| ko: $(KO_BIN) $(KOCACHE) ## Build images using ko | ||
| @$(MAKE) --no-print-directory log-$@ | ||
| @$(eval DIGEST := $(shell LDFLAGS="$(LDFLAGS)" GIT_HASH=$(GIT_HASH) GIT_VERSION=$(GIT_VERSION) \ | ||
| KO_DOCKER_REPO=$(KO_DOCKER_REPO) \ | ||
| KOCACHE=$(KOCACHE) \ | ||
| $< build --bare --platform=all $(KO_TAGS))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Required changes to make the ko tasks work again. They seem to be broken with the ko release I installed.
Proof it works:
$ make ko KO_DOCKER_REPO=ttl.sh/apko-ko-1233456789
2025/11/14 10:59:45 Using base cgr.dev/chainguard/wolfi-base@sha256:77891a12dc762228955294f2207ee1cbd2b127f18dc7c7458203116288dce828 for chainguard.dev/apko
2025/11/14 10:59:45 Using build config apko for chainguard.dev/apko
2025/11/14 10:59:45 Using build config apko for chainguard.dev/apko
2025/11/14 10:59:45 git doesn't contain any tags. Tag info will not be available
2025/11/14 10:59:45 git doesn't contain any tags. Tag info will not be available
2025/11/14 10:59:45 Building chainguard.dev/apko for linux/arm64
2025/11/14 10:59:45 Building chainguard.dev/apko for linux/amd64
2025/11/14 10:59:48 Publishing ttl.sh/apko-ko-1233456789:latest
2025/11/14 10:59:48 Tagging ttl.sh/apko-ko-1233456789:e0c932781ac64bfec15b33a0fc77449e0d869f05
2025/11/14 10:59:48 Tagging ttl.sh/apko-ko-1233456789:e0c9327
2025/11/14 10:59:49 existing blob: sha256:b4e5d0df546ee1b4828576cb9efc6af7b122bbae9e85fdd5c6d08174eb3c6e76
2025/11/14 10:59:49 existing blob: sha256:a7d4b0b6e8bfc15078567178bfd635c84fbebdf1ea3356294fcfb0f2f840fc61
2025/11/14 10:59:49 existing blob: sha256:860894f44c2d8583fd26b330e92b7118424419d76aef06476951517ce2040e77
2025/11/14 10:59:49 existing blob: sha256:db1f7442ecbdd097e06a0a4698e3c94c91340a338b7d793185e89f8f8bdf19be
2025/11/14 10:59:49 existing blob: sha256:76f44e5fadca6ca1ffa5b794e718e804fafa718bf0e1e77736010f7c6ddbab9b
2025/11/14 10:59:49 existing blob: sha256:214e75336e29ac4c5347210b9a7b74be2f6669ff7fa15b17b58532708a7a1649
2025/11/14 10:59:49 existing blob: sha256:250c06f7c38e52dc77e5c7586c3e40280dc7ff9bb9007c396e06d96736cf8542
2025/11/14 10:59:49 existing blob: sha256:cffdd9c646e3fb79026aa7a503df60e83315f46858a39775ce29890dde7c6d79
2025/11/14 10:59:49 existing blob: sha256:1b7766bb78ad668a9cb34d85d41965dc62b98022b5f70951a69135a2468441bd
2025/11/14 10:59:49 existing blob: sha256:ea6587f950df53033ff32385f9faab5feabe8c7969819d0ffcbfb0f00f2ac924
2025/11/14 10:59:49 existing blob: sha256:68d5b3a871fcb204edb73cd774fd1da197f0bf78545cea666c2ad01163bef4b2
2025/11/14 10:59:49 existing blob: sha256:9a705373188b67f52a10d51fd4f467b767e301c096e4c83090eee0e16c327029
2025/11/14 10:59:49 existing blob: sha256:d29d1108f784d19534c2eb9a2567d98bbb8e63792e380eacf9d4f7d2d47e3cfe
2025/11/14 10:59:49 existing blob: sha256:a2661d9cdedc0486379cb3ed49a4aa44c319a9df31b61e1da70d9d8624c20f72
2025/11/14 10:59:49 existing blob: sha256:0b021802ea7252c27b0b2c4928511b1774084e5b6fbb5c66dc7d0f832b30dd1d
2025/11/14 10:59:49 existing blob: sha256:b9869d0d6b5c69b28fe00b07692ac2a1f608b58883783fad675890b69ee6bbb4
2025/11/14 10:59:49 existing blob: sha256:41e50e172b4647e1b0f0399fb45fc6bd0e5e063a1039be9216ff009a100e0092
2025/11/14 10:59:49 existing blob: sha256:d9abdc2149c931dd1795df4c1de676bf5a6eef95219a531c7ee28589802289fa
2025/11/14 10:59:49 existing blob: sha256:1f4d10983e62ad2c98690f0bd9ae22ec0458fbcb25db95e81cfeb2db58f134c8
2025/11/14 10:59:49 existing blob: sha256:35aed235e49d313fb9cd45b199b79ad7d3f5ccf5cf0dc9a5057d1ac9714e4f91
2025/11/14 10:59:49 existing blob: sha256:b4f21e0f00e5c93bbae54c108a70ed07720f1a322e1c0a0464cc4284424d5e02
2025/11/14 10:59:49 existing blob: sha256:69da2c0278bfa3cf24f15a6e5fa57394b85e5531adfe43eeec7458a582fd9c91
2025/11/14 10:59:49 existing blob: sha256:ffa8141ea1304488d30186ab34fef5f95cd8231566e2570c2f785278256cdd74
2025/11/14 10:59:51 pushed blob: sha256:265e7c1dc716d2414b59e0da123bf19887f131fa426711d9c98574547b19babe
2025/11/14 10:59:51 pushed blob: sha256:26f0922b698df622efb3aef5ac1e44e5c5369fed9a3f75ad509ec3a28189f58b
2025/11/14 10:59:52 pushed blob: sha256:ff362b961c34e561eef494b61bc04e0792f6c1b25a318bc65e401a15ee7868bc
2025/11/14 10:59:52 pushed blob: sha256:3aaaa72ce148fbe3db06e6b4bc2bc9fc0d04915058bce3636e45d7e9a0a5efd2
2025/11/14 10:59:52 pushed blob: sha256:c8d709d45b11b120d09f7b736692bbd10bdb1493cac10a5deca4aefb848f639a
2025/11/14 10:59:52 pushed blob: sha256:7b31a72b2ee4ae766d24045b05655420831919c510680334e70d5da0b1fa63ee
2025/11/14 10:59:52 pushed blob: sha256:51470e7b6fb28ef0796eb4f15063a3ef7d60ad3bbd6669d6530411d3d6eeb78e
2025/11/14 10:59:52 pushed blob: sha256:b4c6db526e502583b14306255bc058eb899402d02e41353cbd9f765e11af9b80
2025/11/14 10:59:53 ttl.sh/apko-ko-1233456789:sha256-71226b3e31acf7d9d83e716b135d280f449687eedafbe9cabd41e17c0ff68d12.sbom: digest: sha256:6e12fea4b39d9d8293c487d49e3d40fcf64134439eddff9e44f8b7302bca9aec size: 373
2025/11/14 10:59:53 Published SBOM ttl.sh/apko-ko-1233456789:sha256-71226b3e31acf7d9d83e716b135d280f449687eedafbe9cabd41e17c0ff68d12.sbom
2025/11/14 10:59:53 ttl.sh/apko-ko-1233456789:sha256-0d10bc6c2c4d845559c954f9ccc64afcd84d738e90b78a115f9c6f4f266e3783.sbom: digest: sha256:dc66e227c58a588220d2e56e5dc49c11dc7f2426f13d59306aca18635155dad3 size: 373
2025/11/14 10:59:53 Published SBOM ttl.sh/apko-ko-1233456789:sha256-0d10bc6c2c4d845559c954f9ccc64afcd84d738e90b78a115f9c6f4f266e3783.sbom
2025/11/14 10:59:53 ttl.sh/apko-ko-1233456789:sha256-f2b5615e0f5ca5310f625b3cbaffd0c3397933c1acb4c7c3c9a6eff0b2e2bd85.sbom: digest: sha256:6689c482beebe68763edf678627350a9777a9ec2ff4c4fc42285e7ea37dd538e size: 373
2025/11/14 10:59:53 Published SBOM ttl.sh/apko-ko-1233456789:sha256-f2b5615e0f5ca5310f625b3cbaffd0c3397933c1acb4c7c3c9a6eff0b2e2bd85.sbom
2025/11/14 11:00:18 pushed blob: sha256:b5979135c2289ffcd68b5acbd9a97356b9f053f37c2aca1b3599a439ff196b2e
2025/11/14 11:00:20 ttl.sh/apko-ko-1233456789@sha256:71226b3e31acf7d9d83e716b135d280f449687eedafbe9cabd41e17c0ff68d12: digest: sha256:71226b3e31acf7d9d83e716b135d280f449687eedafbe9cabd41e17c0ff68d12 size: 3002
2025/11/14 11:00:21 pushed blob: sha256:3a0246190e3f59e2869e77ad186f668f0b934944a7121fbb2030791f35ba6d23
2025/11/14 11:00:22 ttl.sh/apko-ko-1233456789@sha256:0d10bc6c2c4d845559c954f9ccc64afcd84d738e90b78a115f9c6f4f266e3783: digest: sha256:0d10bc6c2c4d845559c954f9ccc64afcd84d738e90b78a115f9c6f4f266e3783 size: 3002
2025/11/14 11:00:23 ttl.sh/apko-ko-1233456789:e0c9327: digest: sha256:f2b5615e0f5ca5310f625b3cbaffd0c3397933c1acb4c7c3c9a6eff0b2e2bd85 size: 698
2025/11/14 11:00:24 ttl.sh/apko-ko-1233456789:latest: digest: sha256:f2b5615e0f5ca5310f625b3cbaffd0c3397933c1acb4c7c3c9a6eff0b2e2bd85 size: 698
2025/11/14 11:00:25 ttl.sh/apko-ko-1233456789:e0c932781ac64bfec15b33a0fc77449e0d869f05: digest: sha256:f2b5615e0f5ca5310f625b3cbaffd0c3397933c1acb4c7c3c9a6eff0b2e2bd85 size: 698
2025/11/14 11:00:25 Published ttl.sh/apko-ko-1233456789@sha256:f2b5615e0f5ca5310f625b3cbaffd0c3397933c1acb4c7c3c9a6eff0b2e2bd85
==> Build images using ko
Image Digest ttl.sh/apko-ko-1233456789@sha256:f2b5615e0f5ca5310f625b3cbaffd0c3397933c1acb4c7c3c9a6eff0b2e2bd85Note
In above test I overwrite the repository to push the image.
Running like make ko uses the variable KO_DOCKER_REPO as defined in the Makefile.
0361572 to
632bcde
Compare
- Using make tasks to leverage caching for installing tools. - Fix ko tasks - Use more Makefile agnostic approach
632bcde to
8f73d53
Compare
|
@xnox Any chance you could review this one, simplifies for contributors to run some common dev tasks. |
By using non PHONY tasks for installing tools we can leverage caching:
Using
make -Bwe can force execute those tasks againSimilar I added tasks to install
koandcosignso it is easier for contributors to run the make tasks in case they don't have these tools installed. The tools are installed into the relative./binfolder in this repo (gitignored).E.g.:
Reminder
make -Bcan force a reinstall.Same for
sign-imageit will auto install cosign.Makefile help improvements
Updating help task to have a better documented Makefile
$ make Usage: make <target> help Display help Development: generate Generates jsonschema for apko types. fmt Format all go files checkfmt Check formatting of all go files lint Run linters and checks like golangci-lint test Run go test clean Clean the workspace Compile: apko Builds apko install Builds and moves apko into BINDIR (default /usr/bin) ko-build: ko Build images using ko ko-local Build images locally using ko ko-apply Build the image and apply the manifests ko-resolve Build the image generate the Task YAML Release: snapshot Run Goreleaser in snapshot mode release Run Goreleaser in release mode sign-image Sign images built using ko CI: ci Run all CI tests