Skip to content
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

pre-build step? #42

Open
paleozogt opened this issue Dec 21, 2017 · 4 comments
Open

pre-build step? #42

paleozogt opened this issue Dec 21, 2017 · 4 comments

Comments

@paleozogt
Copy link

Currently, build runs after all the requires run. Could we have a pre_build that runs before the requires? ie,

foobar:
    FROM: foobase
    pre_build: |
       RUN do stuff before foo and bar run
    requires:
       - foo
       - bar
    build: |
       RUN do stuff after foo and bar run

foo:
    build: |
       RUN do foo stuff

bar:
    build: |
       RUN do bar stuff
@epcim
Copy link

epcim commented Feb 14, 2018

This you can solve by creating baz: target and adding it to the requires before foo, bar. Can you be more specific how that would be useful?

BTW: I found it quite useful to to extend docker-make with kind of "makefile" tool. example: https://github.com/epcim/docker-salt-formulas/tree/develop

@paleozogt
Copy link
Author

Here's a more illustrative example:

foobar1:
    FROM: foobase1
    pre_build: |
       RUN do ABC before foo and bar run
    requires:
       - foo
       - bar
    build: |
       RUN do DEF after foo and bar run

foobar2:
    FROM: foobase2
    pre_build: |
       RUN do UVW before foo and bar run
    requires:
       - foo
       - bar
    build: |
       RUN do XYZ after foo and bar run

foo:
    build: |
       RUN do foo stuff

bar:
    build: |
       RUN do bar stuff

I can't just add a baz: target to foo/bar's requires, because I want different things to happen before foo and bar depending on the parent (foobar1, foobar2).

Of course, I could have a foobar1_setup/foobar2_setup in the requires before foo/bar, but it makes for lots of targets (especially when there are large numbers of foobarXXX.

pre_build doesn't necessarily enables functionality that isn't present in DockerMake, but I think it would make for cleaner, easier to maintain DockerMake.yml files.

@avirshup
Copy link
Owner

avirshup commented Feb 22, 2018

Thanks for this suggestion, @paleozogt . I definitely understand the motivation here, although I unfortunately don't believe such functionality could be easily supported with the way the program's written right now.

Curious, though, if you have examples of other build systems that work in this way? Would like to investigate and learn more

@paleozogt
Copy link
Author

Most of my experience with build systems is with Gradle and CMake, tho these are for code building, not image building. At any rate, both Gradle and CMake support a similar idea. For example, Gradle's tasks have dependsOn and finalizedBy, while CMake tasks have add_dependency and POST_BUILD.

I've also been thinking of DockerMake's targets like OOP inheritance. It's not really the right model for how DockerMake works, but it's what made me want to have a "pre" version of build.

Dockerfile is very limited when it comes to making a constellation of complicated images with different base images and packages (some common, some not). DockerMake let me get on top of that complexity and have a DockerMake.yml that's actually maintainable. So, thanks for making this tool!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants