Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .github/workflows/lint_and_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -129,10 +129,10 @@ jobs:
ghcr.io/patrickhoefler/dockerfilegraph:latest \
--version

- name: Get the version on Alpine
- name: Get the version on Ubuntu
run: |
docker run \
ghcr.io/patrickhoefler/dockerfilegraph:alpine \
ghcr.io/patrickhoefler/dockerfilegraph:ubuntu \
--version

- name: Run the Docker image with flags
Expand All @@ -147,14 +147,14 @@ jobs:
--output png \
--dpi 200

- name: Run the Alpine-based Docker image with flags
- name: Run the Ubuntu-based Docker image with flags
run: |
cd examples/dockerfiles
docker run \
--user "$(id -u):$(id -g)" \
--workdir /workspace \
--volume "$(pwd)":/workspace \
ghcr.io/patrickhoefler/dockerfilegraph:alpine \
ghcr.io/patrickhoefler/dockerfilegraph:ubuntu \
--legend \
--output png \
--dpi 200
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@ dockerfilegraph

# dockerfilegraph
Dockerfile.*
!/Dockerfile.alpine
!/Dockerfile.ubuntu
!Dockerfile.golden.dot
!examples/dockerfiles/Dockerfile.large
11 changes: 8 additions & 3 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,20 @@ dockers:
- 'ghcr.io/patrickhoefler/dockerfilegraph:{{ .Major }}'
- 'ghcr.io/patrickhoefler/dockerfilegraph:{{ .Major }}.{{ .Minor }}'
- 'ghcr.io/patrickhoefler/dockerfilegraph:{{ .Major }}.{{ .Minor }}.{{ .Patch }}'

- dockerfile: Dockerfile.alpine
image_templates:
- 'ghcr.io/patrickhoefler/dockerfilegraph:alpine'
- 'ghcr.io/patrickhoefler/dockerfilegraph:latest-alpine'
- 'ghcr.io/patrickhoefler/dockerfilegraph:{{ .Major }}-alpine'
- 'ghcr.io/patrickhoefler/dockerfilegraph:{{ .Major }}.{{ .Minor }}-alpine'
- 'ghcr.io/patrickhoefler/dockerfilegraph:{{ .Major }}.{{ .Minor }}.{{ .Patch }}-alpine'

- dockerfile: Dockerfile.ubuntu
image_templates:
- 'ghcr.io/patrickhoefler/dockerfilegraph:ubuntu'
- 'ghcr.io/patrickhoefler/dockerfilegraph:latest-ubuntu'
- 'ghcr.io/patrickhoefler/dockerfilegraph:{{ .Major }}-ubuntu'
- 'ghcr.io/patrickhoefler/dockerfilegraph:{{ .Major }}.{{ .Minor }}-ubuntu'
- 'ghcr.io/patrickhoefler/dockerfilegraph:{{ .Major }}.{{ .Minor }}.{{ .Patch }}-ubuntu'

brews:
- repository:
owner: patrickhoefler
Expand Down
19 changes: 8 additions & 11 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,23 +1,20 @@
### Release image
FROM ubuntu:oracular-20250225@sha256:aadf9a3f5eda81295050d13dabe851b26a67597e424a908f25a63f589dfed48f
FROM alpine:3.21.3@sha256:a8560b36e8b8210634f77d9f7f9efd7ffa463e380b75e2e74aff4511df3ef88c

LABEL org.opencontainers.image.source="https://github.com/patrickhoefler/dockerfilegraph"

# renovate: datasource=repology depName=ubuntu_24_04/fonts-dejavu versioning=loose
ENV FONTS_DEJAVU_VERSION="2.37-8"
# renovate: datasource=repology depName=alpine_3_21/font-dejavu versioning=loose
ENV FONT_DEJAVU_VERSION="2.37-r5"

# renovate: datasource=repology depName=ubuntu_24_04/graphviz versioning=loose
ENV GRAPHVIZ_VERSION="2.42.4-2build2"
# renovate: datasource=repology depName=alpine_3_21/graphviz versioning=loose
ENV GRAPHVIZ_VERSION="12.2.0-r0"

RUN \
apt-get update \
&& apt-get install -y --no-install-recommends \
fonts-dejavu="${FONTS_DEJAVU_VERSION}" \
RUN apk add --update --no-cache \
font-dejavu="${FONT_DEJAVU_VERSION}" \
graphviz="${GRAPHVIZ_VERSION}" \
&& rm -rf /var/lib/apt/lists/* \
\
# Add a non-root user
&& useradd app
&& adduser -D app

# Run as non-root user
USER app
Expand Down
26 changes: 0 additions & 26 deletions Dockerfile.alpine

This file was deleted.

29 changes: 29 additions & 0 deletions Dockerfile.ubuntu
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
### Release image
FROM ubuntu:oracular-20250225@sha256:aadf9a3f5eda81295050d13dabe851b26a67597e424a908f25a63f589dfed48f

LABEL org.opencontainers.image.source="https://github.com/patrickhoefler/dockerfilegraph"

# renovate: datasource=repology depName=ubuntu_24_10/fonts-dejavu versioning=loose
ENV FONTS_DEJAVU_VERSION="2.37-8"

# renovate: datasource=repology depName=ubuntu_24_10/graphviz versioning=loose
ENV GRAPHVIZ_VERSION="2.42.4-2build2"

RUN \
apt-get update \
&& apt-get install -y --no-install-recommends \
fonts-dejavu="${FONTS_DEJAVU_VERSION}" \
graphviz="${GRAPHVIZ_VERSION}" \
&& rm -rf /var/lib/apt/lists/* \
\
# Add a non-root user
&& useradd app

# Run as non-root user
USER app

# This only works after running `make build-linux`
# or when using goreleaser
COPY dockerfilegraph /

ENTRYPOINT ["/dockerfilegraph"]
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ build: clean
go build $(FLAGS)

build-docker-image-alpine: build-linux
docker build -t dockerfilegraph:alpine -f Dockerfile.alpine .
docker build -t dockerfilegraph:alpine -f Dockerfile .

build-docker-image-ubuntu: build-linux
docker build -t dockerfilegraph:ubuntu -f Dockerfile .
docker build -t dockerfilegraph:ubuntu -f Dockerfile.ubuntu .

build-linux: clean
GOOS=linux go build $(FLAGS)
CGO_ENABLED=0 GOOS=linux go build $(FLAGS)

clean:
go clean
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,20 +53,20 @@ Run `dockerfilegraph` in your project directory to generate a `Dockerfile.pdf` w

#### Docker

- **Alpine-based** (Graphviz 12.2):
- **Alpine-based** (Graphviz 12.2) - **Default**:

```shell
docker run --rm --user "$(id -u):$(id -g)" \
-v "$(pwd)":/workspace -w /workspace \
ghcr.io/patrickhoefler/dockerfilegraph:alpine
ghcr.io/patrickhoefler/dockerfilegraph
Comment thread
patrickhoefler marked this conversation as resolved.
```

- **Ubuntu-based** (Graphviz 2.42):

```shell
docker run --rm --user "$(id -u):$(id -g)" \
-v "$(pwd)":/workspace -w /workspace \
ghcr.io/patrickhoefler/dockerfilegraph
ghcr.io/patrickhoefler/dockerfilegraph:ubuntu
```

#### Homebrew
Expand Down
34 changes: 17 additions & 17 deletions internal/cmd/testdata/Dockerfile.golden.dot
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
digraph G {
graph [bb="0,0,543,252",
graph [bb="0,0,541.25,252",
Comment thread
patrickhoefler marked this conversation as resolved.
compound=true,
nodesep=1.00,
rankdir=LR,
Expand All @@ -10,63 +10,63 @@ digraph G {
fontcolor=grey20,
height=0.5,
label="ubuntu:l...887c2c7ac",
pos="86,234",
pos="85.625,234",
shape=box,
style="dashed,rounded",
width=2.3056];
width=2.2951];
stage_0 [height=0.5,
label=ubuntu,
pos="285.5,234",
pos="284.25,234",
shape=box,
style=rounded,
width=2];
external_image_0 -> stage_0 [pos="e,213.41,234 169.04,234 180.32,234 191.9,234 203.17,234"];
external_image_0 -> stage_0 [pos="e,212.06,234 168.59,234 179.19,234 190.05,234 200.66,234"];
stage_2 [fillcolor=grey90,
height=0.5,
label=release,
pos="471,126",
pos="469.25,126",
shape=box,
style="filled,rounded",
width=2];
stage_0 -> stage_2 [arrowhead=empty,
pos="e,439.19,144.14 317.21,215.92 348.31,197.62 396.52,169.25 430.45,149.28",
pos="e,437.05,144.41 316.29,215.68 346.92,197.6 393.91,169.87 427.52,150.04",
style=dashed];
external_image_1 [color=grey20,
fontcolor=grey20,
height=0.5,
label="golang:1...b738433da",
pos="86,126",
pos="85.625,126",
shape=box,
style="dashed,rounded",
width=2.3889];
width=2.3785];
stage_1 [height=0.5,
label="build-tool-depend...",
pos="285.5,126",
pos="284.25,126",
shape=box,
style=rounded,
width=2.1528];
external_image_1 -> stage_1 [pos="e,207.99,126 172.19,126 180.65,126 189.25,126 197.73,126"];
width=2.1389];
external_image_1 -> stage_1 [pos="e,206.99,126 171.72,126 179.6,126 187.6,126 195.5,126"];
stage_1 -> stage_2 [arrowhead=empty,
pos="e,398.82,126 363.26,126 371.64,126 380.19,126 388.62,126",
pos="e,396.78,126 361.53,126 369.37,126 377.37,126 385.28,126",
style=dashed];
external_image_2 [color=grey20,
fontcolor=grey20,
height=0.5,
label=buildcache,
pos="86,18",
pos="85.625,18",
shape=box,
style="dashed,rounded",
width=2];
external_image_2 -> stage_1 [arrowhead=ediamond,
pos="e,251.34,107.86 120.06,36.077 153.1,54.144 204.09,82.03 240.53,101.96",
pos="e,249.73,107.59 119.98,36.321 152.61,54.241 202.51,81.651 238.55,101.45",
style=dotted];
external_image_3 [color=grey20,
fontcolor=grey20,
height=0.5,
label=scratch,
pos="285.5,18",
pos="284.25,18",
shape=box,
style="dashed,rounded",
width=2];
external_image_3 -> stage_2 [pos="e,439.19,107.86 317.21,36.077 348.31,54.378 396.52,82.753 430.45,102.72"];
external_image_3 -> stage_2 [pos="e,437.05,107.59 316.29,36.321 346.92,54.396 393.91,82.126 427.52,101.96"];
}