Skip to content

builder: add an option for specifying build target#32496

Merged
vieux merged 1 commit intomoby:masterfrom
tonistiigi:build-target
Apr 11, 2017
Merged

builder: add an option for specifying build target#32496
vieux merged 1 commit intomoby:masterfrom
tonistiigi:build-target

Conversation

@tonistiigi
Copy link
Member

fixes #32104

This is a first pass of docker build --target that lets you specify an intermediate build stage that you wish to build/tag instead of the last one. The stages are still executed sequentially and only skipped from the end of the file if possible. Skipping other stages that do not have dependencies should be a future optimization that doesn't change the UI(cc @AkihiroSuda).

@dnephin @vdemeester

Signed-off-by: Tonis Tiigi [email protected]

Copy link
Member

@dnephin dnephin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Design LGTM

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of this, how about

func (ic *imageContexts) isCurrentTarget(target string) string {
    if target == "" {
        return false
    }
    return strings.EqualFold(ic.currentName, target)
}

That way the EqualFold is only done in one place.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about this for a description: "Exit after target build stage has completed".

The "default" is actually "", so it can probably be omitted.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Exit after target build stage has completed" is specific to current implementation. When the implementation changes in a future release, it should be invisible to the user, some cases just become faster.

Do you want me to skip the hint about default. I added it so that it is clear that passing this value is optional.

Copy link
Member

@dnephin dnephin Apr 10, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we use the command.From constant here? I believe the n.Value is already normalzied to lowercase.

@tonistiigi
Copy link
Member Author

@dnephin Updated. Lmk if you still prefer to tweak the usage message for the flag.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this may still need the check for b.options.Target != "", right?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

Copy link
Member

@dnephin dnephin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess we can always fix the wording of the help flag later, so if the build is green, LGTM

Copy link
Member

@dnephin dnephin Apr 10, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The current wording is just a bit ambiguous. On first reading I thought it was saying 'This flags sets the target build stage to the value of "build"'.

That doesn't really tell the user how the behaviour will change (target is what gets tagged, some context don't build, etc).

Maybe something like: "Name of the build-stage to build and optionally tag", "Build target build stage", or something like that?

@vieux
Copy link
Contributor

vieux commented Apr 11, 2017

LGTM

@cancan101
Copy link

Is there an issue filed tracking this feature:

Skipping other stages that do not have dependencies should be a future optimization that doesn't change the UI

@tonistiigi
Copy link
Member Author

@cancan101 This is implemented in https://github.com/moby/buildkit/ , moby will get support with buildkit integration.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Proposal: add a way to specify build target by name

6 participants