Skip to content

history: export build using history command support #652

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

Merged
merged 3 commits into from
Apr 23, 2025

Conversation

@crazy-max crazy-max force-pushed the buildx-history-cmd branch 10 times, most recently from 02c9436 to 684c055 Compare April 11, 2025 09:52
@crazy-max crazy-max requested a review from tonistiigi April 11, 2025 12:13
@crazy-max crazy-max marked this pull request as ready for review April 11, 2025 12:13
@crazy-max crazy-max self-assigned this Apr 11, 2025
Comment on lines +96 to +97
Sources?: any;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
Copy link
Member Author

Choose a reason for hiding this comment

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

As follow-up we could print the sources along the error logs similar to inspect command:

Name:           buildx (binaries)
Context:        /mnt/x/dev/www/github/docker_org/buildx
Dockerfile:     Dockerfile
VCS Repository: https://github.com/crazy-max/buildx.git
VCS Revision:   f8de3c3bdcb956aa4b6671d36644c7af7a7989c5
Target:         binaries
Platforms:      linux/amd64
Keep Git Dir:   true

Started:        2025-04-10 19:53:59
Duration:       58.7s
Error:          Unknown process "/bin/sh -c   set -e\n  xx-go --wrap\n  DESTDIR=/usr/bin VERSION=$(cat /buildx-version/version) REVISION=$(cat /buildx-version/revision) GO_EXTRA_LDFLAGS=\"-s -w\" ./hack/build\n  file /usr/bin/docker-buildx\n  xx-verify --static /usr/bin/docker-buildx\n" did not complete successfully: exit code: 1
Build Steps:    14/15 (27% cached)

Image Resolve Mode:     local

Dockerfile:80
--------------------
  79 |     ARG GO_EXTRA_FLAGS
  80 | >>> RUN --mount=type=bind,target=. \
  81 | >>>   --mount=type=cache,target=/root/.cache \
  82 | >>>   --mount=type=cache,target=/go/pkg/mod \
  83 | >>>   --mount=type=bind,from=buildx-version,source=/buildx-version,target=/buildx-version <<EOT
  84 | >>>   set -e
  85 | >>>   xx-go --wrap
  86 | >>>   DESTDIR=/usr/bin VERSION=$(cat /buildx-version/version) REVISION=$(cat /buildx-version/revision) GO_EXTRA_LDFLAGS="-s -w" ./hack/build
  87 | >>>   file /usr/bin/docker-buildx
  88 | >>>   xx-verify --static /usr/bin/docker-buildx
  89 | >>> EOT
  90 |
--------------------

Logs:
> => [buildx-build 1/1] RUN --mount=type=bind,target=.   --mount=type=cache,target=/root/.cache   --mount=type=cache,target=/go/pkg/mod   --mount=type=bind,from=buildx-version,source=/buildx-version,target=/buildx-version <<EOT (set -e...):
> + CGO_ENABLED=0 go build -mod vendor -trimpath -ldflags '-X github.com/docker/buildx/version.Version=v0.23.0-rc1-2-gf8de3c3b.m -X github.com/docker/buildx/version.Revision=f8de3c3bdcb956aa4b6671d36644c7af7a7989c5.m -X github.com/docker/buildx/version.Package=github.com/docker/buildx -s -w' -o /usr/bin/docker-buildx ./cmd/buildx
> # github.com/docker/buildx/commands
> commands/bake.go:428:6: declared and not used: resp
> commands/bake.go:429:16: undefined: sp

Enable --debug to see stack traces for error
Print build logs: docker buildx history logs mutgx2wmrwjpu4jm17yenzwn9

@crazy-max crazy-max force-pushed the buildx-history-cmd branch from 684c055 to 1354fce Compare April 16, 2025 08:23
@crazy-max crazy-max force-pushed the buildx-history-cmd branch from 1354fce to 4731c96 Compare April 16, 2025 08:25
}

// wait 3 seconds to ensure build records are finalized: https://github.com/moby/buildkit/pull/5109
await Util.sleep(3);
Copy link
Member

Choose a reason for hiding this comment

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

Ah, I forgot this. Buildx finalizes trace on buildx history trace automatically. This could be used in here instead but would be messy. We should update buildx history export to do it as well (eg. when a flag is set).

Copy link
Member Author

Choose a reason for hiding this comment

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

We should update buildx history export to do it as well (eg. when a flag is set).

Yes sounds good

Copy link
Member Author

Choose a reason for hiding this comment

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

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.

buildx(history): use history command when available
2 participants