Docker with make: build image on Dockerfile change

后端 未结 2 1415
北荒
北荒 2021-02-06 05:10

I playing with Docker and make utility and try to write rule which rebuilds docker image only on Dockerfile change.
My project structure looks like:

 tree .         


        
2条回答
  •  时光取名叫无心
    2021-02-06 05:49

    Your "targets" default run and build are "phony" targets. That is an abstract concept, not a real file. Such phony targets, should not have a recipe (because you can't make them). They should instead depend on real files, or perhaps other phony targets, and so on, but everything must eventually depend on real files only.

    Your phony targets should be marked as such

    .PHONY: default run build
    

    The real targets, on the other hand, should have a recipe - the recipe makes that target.

    So, first depend your phony targets, without a recipe, on a real target(s).

    Then have real targets have recipes.

    I have posted some guidelines at makefile enforce library dependency ordering

提交回复
热议问题