Skip to content

Commit

Permalink
Merge pull request #23 from ktock/refactoruireadme
Browse files Browse the repository at this point in the history
Refactor UI
  • Loading branch information
ktock authored May 17, 2022
2 parents 497b9f2 + f21e590 commit 89a737c
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 34 deletions.
55 changes: 26 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[[⬇️ **Download]**](https://github.com/ktock/buildg/releases)
[[📖 **Command reference]**](#command-reference)

# buildg: A tool to interactively debug Dockerfile
# buildg: Interactive debugger for Dockerfile

`buildg` is a tool to interactively debug Dockerfile based on [BuildKit](https://github.com/moby/buildkit).

Expand Down Expand Up @@ -48,7 +48,7 @@ Store this Dockerfile to somewhere (e.g. `/tmp/ctx/Dockerfile`) then run `buildg

```console
$ buildg.sh debug --image=ubuntu:22.04 /tmp/ctx
WARN[2022-05-10T10:21:14Z] using host network as the default
WARN[2022-05-17T09:01:16Z] using host network as the default
#1 [internal] load build definition from Dockerfile
#1 transferring dockerfile: 195B done
#1 DONE 0.1s
Expand All @@ -58,39 +58,36 @@ WARN[2022-05-10T10:21:14Z] using host network as the default
#2 DONE 0.1s

#3 [internal] load metadata for docker.io/library/busybox:latest
#3 DONE 3.1s

#4 [build2 1/2] FROM docker.io/library/busybox@sha256:d2b53584f580310186df7a2055ce3ff83cc0df6caacf1e3489bff8cf5d0af5d8
#4 resolve docker.io/library/busybox@sha256:d2b53584f580310186df7a2055ce3ff83cc0df6caacf1e3489bff8cf5d0af5d8 0.0s done
#4 sha256:50e8d59317eb665383b2ef4d9434aeaa394dcd6f54b96bb7810fdde583e9c2d1 772.81kB / 772.81kB 0.2s done
INFO[2022-05-17T09:01:19Z] debug session started. type "help" for command reference.
Filename: "Dockerfile"
=> 1| FROM busybox AS build1
2| RUN echo hello > /hello
3|
4| FROM busybox AS build2
=> 5| RUN echo hi > /hi
=> 4| FROM busybox AS build2
5| RUN echo hi > /hi
6|
7| FROM scratch
8| COPY --from=build1 /hello /
>>> break 2
>>> breakpoints
[0]: line: Dockerfile:2
(buildg) break 5
(buildg) breakpoints
[0]: line: Dockerfile:5
[on-fail]: breaks on fail
>>> continue
#4 extracting sha256:50e8d59317eb665383b2ef4d9434aeaa394dcd6f54b96bb7810fdde583e9c2d1 0.0s done
#4 DONE 0.3s

#5 [build1 2/2] RUN echo hello > /hello
#5 ...
(buildg) continue
#3 DONE 3.2s

#6 [build2 2/2] RUN echo hi > /hi
Breakpoint: line: Dockerfile:2: reached
#4 [build2 1/2] FROM docker.io/library/busybox@sha256:d2b53584f580310186df7a2055ce3ff83cc0df6caacf1e3489bff8cf5d0af5d8
#4 resolve docker.io/library/busybox@sha256:d2b53584f580310186df7a2055ce3ff83cc0df6caacf1e3489bff8cf5d0af5d8 0.0s done
#4 sha256:50e8d59317eb665383b2ef4d9434aeaa394dcd6f54b96bb7810fdde583e9c2d1 0B / 772.81kB 0.2s
#4 sha256:50e8d59317eb665383b2ef4d9434aeaa394dcd6f54b96bb7810fdde583e9c2d1 772.81kB / 772.81kB 0.9s done
Breakpoint[0]: reached line: Dockerfile:5
Filename: "Dockerfile"
1| FROM busybox AS build1
*=> 2| RUN echo hello > /hello
2| RUN echo hello > /hello
3|
4| FROM busybox AS build2
5| RUN echo hi > /hi
>>> exec --image sh
*=> 5| RUN echo hi > /hi
6|
7| FROM scratch
8| COPY --from=build1 /hello /
(buildg) exec --image sh
# cat /etc/os-release
PRETTY_NAME="Ubuntu 22.04 LTS"
NAME="Ubuntu"
Expand All @@ -105,11 +102,11 @@ BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
UBUNTU_CODENAME=jammy
# ls /debugroot/
bin dev etc hello home proc root tmp usr var
# cat /debugroot/hello
hello
bin dev etc hi home proc root tmp usr var
# cat /debugroot/hi
hi
#
>>> quit
(buildg) quit
```

## Install
Expand Down
2 changes: 1 addition & 1 deletion debug.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ func (d *debugController) handle(ctx context.Context, handler *handler) error {
case msg := <-d.eventCh:
logrus.Debugf("got debug event %q", msg.debugID)
if locs, err := d.getLocation(msg.vertex.String()); err != nil {
logrus.WithError(err).Warnf("failed to get location info")
logrus.WithError(err).Debug("failed to get location info")
} else {
if err := handler.handle(ctx, msg, locs); err != nil {
if err == nil && ctx.Err() != nil {
Expand Down
6 changes: 3 additions & 3 deletions handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (

const (
promptEnvKey = "BUILDG_PS1"
defaultPrompt = ">>> "
defaultPrompt = "(buildg) "
)

var errExit = errors.New("exit")
Expand Down Expand Up @@ -215,10 +215,10 @@ func (h *handler) dispatch(ctx context.Context, info *registeredStatus, locs []*
}
continueRead = true
app := cli.NewApp()
rootCmd := "handler"
rootCmd := "buildg"
app.Name = rootCmd
app.HelpName = rootCmd
app.Usage = "Debug command handler"
app.Usage = "Interactive debugger for Dockerfile"
app.UsageText = "command [command options] [arguments...]"
app.ExitErrHandler = func(context *cli.Context, err error) {}
app.UseShortOptionHandling = true
Expand Down
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ import (

func main() {
app := cli.NewApp()
app.Usage = "A debug tool for Dockerfile based on BuildKit"
app.Usage = "Interactive debugger for Dockerfile"
app.Flags = []cli.Flag{
cli.BoolFlag{
Name: "debug",
Expand Down

0 comments on commit 89a737c

Please sign in to comment.