Created
November 3, 2021 00:53
-
-
Save inspirit941/c9284131b55895a745b1b8b73db431f4 to your computer and use it in GitHub Desktop.
pack build 과정 팔로업
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func (l *LifecycleExecution) Run(ctx context.Context, phaseFactoryCreator PhaseFactoryCreator) error { | |
phaseFactory := phaseFactoryCreator(l) | |
var buildCache Cache | |
if l.opts.CacheImage != "" { | |
cacheImage, err := name.ParseReference(l.opts.CacheImage, name.WeakValidation) | |
if err != nil { | |
return fmt.Errorf("invalid cache image name: %s", err) | |
} | |
buildCache = cache.NewImageCache(cacheImage, l.docker) | |
} else { | |
buildCache = cache.NewVolumeCache(l.opts.Image, "build", l.docker) | |
} | |
l.logger.Debugf("Using build cache volume %s", style.Symbol(buildCache.Name())) | |
if l.opts.ClearCache { | |
if err := buildCache.Clear(ctx); err != nil { | |
return errors.Wrap(err, "clearing build cache") | |
} | |
l.logger.Debugf("Build cache %s cleared", style.Symbol(buildCache.Name())) | |
} | |
launchCache := cache.NewVolumeCache(l.opts.Image, "launch", l.docker) | |
if !l.opts.UseCreator { | |
l.logger.Info(style.Step("DETECTING")) | |
if err := l.Detect(ctx, l.opts.Network, l.opts.Volumes, phaseFactory); err != nil { | |
return err | |
} | |
l.logger.Info(style.Step("ANALYZING")) | |
if err := l.Analyze(ctx, l.opts.Image.String(), l.opts.Network, l.opts.Publish, l.opts.DockerHost, l.opts.ClearCache, buildCache, phaseFactory); err != nil { | |
return err | |
} | |
l.logger.Info(style.Step("RESTORING")) | |
if l.opts.ClearCache { | |
l.logger.Info("Skipping 'restore' due to clearing cache") | |
} else if err := l.Restore(ctx, l.opts.Network, buildCache, phaseFactory); err != nil { | |
return err | |
} | |
l.logger.Info(style.Step("BUILDING")) | |
if err := l.Build(ctx, l.opts.Network, l.opts.Volumes, phaseFactory); err != nil { | |
return err | |
} | |
l.logger.Info(style.Step("EXPORTING")) | |
return l.Export(ctx, l.opts.Image.String(), l.opts.RunImage, l.opts.Publish, l.opts.DockerHost, l.opts.Network, buildCache, launchCache, l.opts.AdditionalTags, phaseFactory) | |
} | |
return l.Create(ctx, l.opts.Publish, l.opts.DockerHost, l.opts.ClearCache, l.opts.RunImage, l.opts.Image.String(), l.opts.Network, buildCache, launchCache, l.opts.AdditionalTags, l.opts.Volumes, phaseFactory) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment