Skip to content

Commit

Permalink
Merge pull request #953 from traPtitech/fix/builder/close-ch
Browse files Browse the repository at this point in the history
Runtimeアプリのビルド設定で、存在しないディレクトリをContextに指定するとbuilderがハングするのを修正
  • Loading branch information
pirosiki197 authored Aug 21, 2024
2 parents 59b03f4 + 78bd2f8 commit 965f607
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions pkg/usecase/builder/build_buildkit.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,14 @@ func (s *builderService) solveDockerfile(
env map[string]string,
ch chan *buildkit.SolveStatus,
) error {
// ch must be closed when this function returns because it is listened by progress ui display
var channelClosed bool = false
defer func() {
if !channelClosed {
close(ch)
}
}()

ctxMount, err := fsutil.NewFS(contextDir)
if err != nil {
return errors.Wrap(err, "invalid context mount dir")
Expand All @@ -123,6 +131,7 @@ func (s *builderService) solveDockerfile(
if err != nil {
return errors.Wrap(err, "invalid dockerfile mount dir")
}

opts := buildkit.SolveOpt{
Exports: []buildkit.ExportEntry{{
Type: buildkit.ExporterImage,
Expand All @@ -144,7 +153,11 @@ func (s *builderService) solveDockerfile(
),
Session: s.authSessions(),
}

_, err = s.buildkit.Solve(ctx, nil, opts, ch)
// ch is closed by buildkit.Solve
channelClosed = true

return err
}

Expand Down

0 comments on commit 965f607

Please sign in to comment.