Skip to content

Hint: include -> eval#1

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 馃槃

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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