Skip to content

engine: dcbad can build images [ch1371]#1048

Merged
maiamcc merged 9 commits into
masterfrom
maiamcc/dcbad-can-build-images
Jan 18, 2019
Merged

engine: dcbad can build images [ch1371]#1048
maiamcc merged 9 commits into
masterfrom
maiamcc/dcbad-can-build-images

Conversation

@maiamcc

@maiamcc maiamcc commented Jan 18, 2019

Copy link
Copy Markdown
Contributor

tests to follow but want a check first that i'm on a reasonable track

@maiamcc
maiamcc requested review from jazzdan and nicks January 18, 2019 15:45
Comment thread internal/build/container_test.go Outdated
f.WriteFile("missing.txt", "missing")

ref, err := f.b.BuildDockerfile(f.ctx, f.ps, f.getNameFromTest(), df, f.Path(), model.EmptyMatcher, model.DockerBuildArgs{})
ref, err := f.b.BuildDockerfile(f.ctx, f.ps, f.getNameFromTest(), df, f.Path(), model.EmptyMatcher, model.DockerBuildArgs{}, false)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

have you considered having a separate Tag() call?

i.e., docker tag fortune:tilt-cabcab fortune:latest

(i also don't think TagImage should be part of the normal BuildDockerfile call, but we can make that decision independently)

Comment thread internal/build/image_builder.go Outdated
tag, err := digestAsTag(dig)
if err != nil {
return nil, errors.Wrap(err, "TagImage")
func (d *dockerImageBuilder) TagImage(ctx context.Context, ref reference.Named, dig digest.Digest, tagLatest bool) (reference.NamedTagged, error) {

@nicks nicks Jan 18, 2019

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

maybe there should be two separate methods?
TagImage(reference.NamedTagged, dig Digest)
TagImageFromDigest(reference.Named, dig Digest)

presumably, the second one could use the first one

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

no longer relevant after refactor

case model.ImageTarget:
iTargets = append(iTargets, s)
case model.DockerComposeTarget:
dcTargets = append(dcTargets, s)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

should probably return nil if there's a spec it doesn't recognize, rather than quietly dropping it on the floor. see the other extract() method

return store.BuildResultSet{}, err
}
if haveImage {
logger.Get(ctx).Infof("~~ i'm building ur image for: %s", dcTarget.Name)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

O.o

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

😅

// NOTE(maia): we assume that this func takes one DC target and up to one image target
// corresponding to that service. If this func ever supports specs for more than one
// service at once, we'll have to match up image build results to DC target by ref.
ref, err = bd.ibd.build(ctx, iTarget, currentState[iTarget.ID()], ps, true)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

maybe this is a good sign that this needs to be broken out into a common utility class? it seems very weird, architecturally, for one ImageBuildAndDeployer to container another.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

will do

@maiamcc
maiamcc force-pushed the maiamcc/dcbad-can-build-images branch from f7cd64a to f719591 Compare January 18, 2019 19:39
@maiamcc

maiamcc commented Jan 18, 2019

Copy link
Copy Markdown
Contributor Author

@nicks @jazzdan this is ready for y'all

}
}

func (icb *ImageAndCacheBuilder) Build(ctx context.Context, iTarget model.ImageTarget, state store.BuildState, ps *PipelineState, canSkipPush bool) (reference.NamedTagged, error) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

should canSkipPush be a method of this struct? it seems like a weird thing to be a parameter

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

yeahhh we'd need to mess with the way we k8s env in and how it interacts with Docker Compose -- because we still populate this value even when we're doing Docker Compose stuff instead of worrying about k8s :-/ i'll leave a todo

} else {
// !shouldBuild implies that Tilt will take care of building, which implies that
// we should recreate container so that we pull the new image
// NOTE(maia): this is maybe the WRONG thing to do if we're deploying a service

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

for what it's worth, this is another reason why our k8s-based builder uses content-based tags: it's a way to make sure kubernetes creates a new pod iff the contents changed.

@@ -0,0 +1,175 @@
package build

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

fwiw, i probably would have left this in the same package...i feel like moving it to a different package forced you to make a bunch of odd architecture decisions around mode, which distracts from the main focus of this PR

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

😅 legit!

@maiamcc
maiamcc force-pushed the maiamcc/dcbad-can-build-images branch from a580fda to 571c690 Compare January 18, 2019 21:46
@maiamcc
maiamcc merged commit b07fc46 into master Jan 18, 2019
@maiamcc
maiamcc deleted the maiamcc/dcbad-can-build-images branch January 18, 2019 21:57
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

Successfully merging this pull request may close these issues.

2 participants