Skip to content

Commit

Permalink
feat: add graphviz generator
Browse files Browse the repository at this point in the history
  • Loading branch information
kimdre committed Aug 7, 2024
1 parent cc176f5 commit eb683a2
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions internal/docker/compose.go
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,33 @@ func DeployCompose(ctx context.Context, dockerCli command.Cli, project *types.Pr
WaitTimeout: time.Duration(deployConfig.Timeout) * time.Second,
}

vizOpts := api.VizOptions{
IncludeNetworks: true,
IncludePorts: true,
IncludeImageName: true,
Indentation: " ",
}
graph, err := service.Viz(ctx, project, vizOpts)
if err != nil {
return err
}

// Write the graph to a file
f, err := os.Create("docker-compose-graph.dot")
if err != nil {
return err
}

_, err = f.WriteString(graph)
if err != nil {
return err
}

err = f.Close()
if err != nil {
return err
}

err = service.Up(ctx, project, api.UpOptions{
Create: createOpts,
Start: startOpts,
Expand Down

0 comments on commit eb683a2

Please sign in to comment.