Skip to content
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

Additional options for large graphs #272

Closed
ebekebe opened this issue Jan 30, 2023 · 1 comment
Closed

Additional options for large graphs #272

ebekebe opened this issue Jan 30, 2023 · 1 comment

Comments

@ebekebe
Copy link

ebekebe commented Jan 30, 2023

This is a follow up of #258.

To have a better benchmark I created a skeleton Dockerfile from our real-world 300 lines Dockerfile:

FROM --platform=linux/amd64 ubuntu:22.04 AS ubuntu_amd64

FROM --platform=linux/arm64 ubuntu:22.04 AS ubuntu_arm64

FROM ubuntu:22.04 AS ubuntu_with_amd64_emulation
COPY --from=ubuntu_amd64 /etc/apt/sources.list /etc/apt/sources.list.amd64
COPY --from=ubuntu_arm64 /etc/apt/sources.list /etc/apt/sources.list.arm64
COPY --from=ubuntu_amd64 /usr/bin/cat ./cat
COPY --from=ubuntu_arm64 /usr/bin/cat ./cat

FROM alpine:3.12.0 AS a_dependency

FROM ubuntu_with_amd64_emulation AS base
COPY --from=a_dependency /bin/cat /tmp/cat
COPY --from=docker.io/alpine:3.14 /bin/cat /tmp/cat
COPY --from=docker.io/alpine:3.14.1 /bin/cat /tmp/cat
COPY --from=docker.io/alpine:3.14.2 /bin/cat /tmp/cat
COPY --from=docker.io/alpine:3.14.3 /bin/cat /tmp/cat
COPY --from=docker.io/alpine:3.14.4 /bin/cat /tmp/cat
COPY --from=docker.io/alpine:3.14.5 /bin/cat /tmp/cat
COPY --from=docker.io/alpine:3.14.6 /bin/cat /tmp/cat
COPY --from=docker.io/alpine:3.14.7 /bin/cat /tmp/cat
COPY --from=docker.io/alpine:3.14.8 /bin/cat /tmp/cat
COPY --from=docker.io/alpine:3.15 /bin/cat /tmp/cat
COPY --from=docker.io/alpine:3.15.1 /bin/cat /tmp/cat
COPY --from=docker.io/alpine:3.15.2 /bin/cat /tmp/cat
COPY --from=docker.io/alpine:3.15.3 /bin/cat /tmp/cat
COPY --from=docker.io/alpine:3.15.4 /bin/cat /tmp/cat
COPY --from=docker.io/alpine:3.15.5 /bin/cat /tmp/cat
COPY --from=docker.io/alpine:3.15.6 /bin/cat /tmp/cat
COPY --from=docker.io/alpine:3.16.1 /bin/cat /tmp/cat
COPY --from=docker.io/alpine:3.16.2 /bin/cat /tmp/cat
COPY --from=docker.io/alpine:3.16.3 /bin/cat /tmp/cat
COPY --from=docker.io/alpine:3.16 /bin/cat /tmp/cat

FROM --platform=$BUILDPLATFORM ubuntu:22.04 AS build_buildplatform
RUN --mount=type=cache,target=/root/.m2/repository echo mvn dependencies ...
RUN --mount=type=cache,target=/root/.m2/repository echo mvn package ...

FROM base as test
COPY --from=build_buildplatform /bin/cat /tmp/cat
COPY --from=build_buildplatform /bin/cat /tmp/cat
COPY --from=build_buildplatform /bin/cat /tmp/cat
RUN --mount=type=cache,target=/root/.m2/repository echo mvn verify ...

FROM base
COPY --from=build_buildplatform /bin/cat /tmp/cat
COPY --from=build_buildplatform /bin/cat /tmp/cat

This file will render the same nodes and edges as the original and it also includes a couple of aspects of the original.
Feel free to include this file as a benchmark in your repo.

The rendering currently looks like this (dockerfilegraph -c):
Dockerfile (1)

(Note that I updated the Dockerfile above with real alpine versions so it would build. The images here are generated with fake tags.)

If I play with the flatten option, it doesn't really get more compact/readble (dockerfilegraph -c -u 4):
Dockerfile (3)

The output I prefer looks like this and it is achieved by setting nodesep=0.25,ranksep=2 in the canon file generated by dockerfilegraph -c -o canon:

Dockerfile (4)

So I would love to see an option to override nodesep and ranksep directly from the dockerfilegraph CLI. Maybe even allow overwriting any graph-wide settings.

Another thing to notice is that the nodes for external images don't grow with the image name, but the image name is elided aggressively, so it is hard (and sometimes impossible) to discern the images. This is a problem in the real-world file as well and there it is even more pronounced, since all images use 8-character git hashes as tags. Here, I would like to see an option to set the maximum text length of a node.

Finally, this Dockerfile uses --platform=.... Visually indicating that --platform is used for a node, would help to understand the multi-arch behaviour of this Dockerfile better. I could imagine changing the background color and/or allowing renderings for each target platform individually.

@patrickhoefler
Copy link
Owner

patrickhoefler commented Feb 5, 2023

Hey Benjamin, once again thanks for your feedback!

The --nodesep, --ranksep and --max-label-length flags are now available.

Finally, this Dockerfile uses --platform=.... Visually indicating that --platform is used for a node, would help to understand the multi-arch behaviour of this Dockerfile better.

Would it help you if the --platform value shows up in the node label?

Something like:

╭────────────────────────────╮
│ ubuntu_amd64 [linux/amd64] │  
╰────────────────────────────╯

[...] allowing renderings for each target platform individually.

I'm not quite sure what you mean by that, could you please elaborate? Also, please feel free to create a separate issue for the --platform enhancement, we could then already close this one.

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

No branches or pull requests

2 participants