Skip to content

Hint: include -> evalΒ #1

@koshic

Description

@koshic

Hello @philpep, currently I work on the same task - automation for a large docker repo. Your article https://philpep.org/blog/a-makefile-for-your-dockerfiles was very helpful for me, this is a really brilliant solution πŸ‘

And recently I discovered a bit simpler way to build dependencies than including extra makefile (I work with docker files paths directly, without intermediate variable):

define build-dependencies
$(1): $(shell \
	cat $(1) \
	| grep -E '^FROM *$(registry)/$(base-tag)/[^ :]*($$| )' -o \
	| sed 's|FROM *$(registry)/$(base-tag)/||' \
	| sed -E 's| ?$$|/Dockerfile|')
endef

$(foreach file,$(docker-files),$(eval $(call build-dependencies,$(file))))

As you can see, eval works like include, and other targets work as expected. Also, you don't need to maintain .depends.mk file. For debug purposes, you can replace eval with info.

Hope this helps πŸ˜„

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions