From 9d390e286712f89e4993c75dccd4f10f9912d186 Mon Sep 17 00:00:00 2001 From: Andreas Galazis Date: Sun, 2 Apr 2023 12:05:15 +0300 Subject: [PATCH 1/3] Update Dockerfile --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 9e46fcd..8da15c2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -8,7 +8,7 @@ RUN go mod download COPY . . -RUN apk -q --no-progress add git make; \ +RUN apk -q --no-progress add git make graphviz ttf-dejavu; \ make build FROM alpine From 059cef0263b708040debf8fe409e7a26d8010c72 Mon Sep 17 00:00:00 2001 From: Andreas Galazis Date: Sun, 9 Apr 2023 13:06:33 +0300 Subject: [PATCH 2/3] feat(graphviz): bundle graphviz --- Dockerfile | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/Dockerfile b/Dockerfile index 8da15c2..290d681 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,4 @@ FROM golang:1.16.5-alpine3.12 as builder - WORKDIR /app COPY go.mod go.sum ./ @@ -8,9 +7,19 @@ RUN go mod download COPY . . -RUN apk -q --no-progress add git make graphviz ttf-dejavu; \ - make build +RUN apk -q --no-progress add git make \ + && make build FROM alpine -COPY --from=builder /app/inframap /app/ -ENTRYPOINT ["/app/inframap"] + +RUN apk -q --no-progress add graphviz ttf-dejavu\ + && addgroup -g 1000 inframap \ + && adduser -u 1000 -G inframap -s /bin/ash -D inframap + +USER 1000 + +WORKDIR /home/inframap + +COPY --from=builder /app/inframap /home/inframap + +ENTRYPOINT ["inframap"] From c4f57d3087f2f4093bc9aa8b659bf2ec272db768 Mon Sep 17 00:00:00 2001 From: xescugc Date: Mon, 28 Aug 2023 16:36:17 +0200 Subject: [PATCH 3/3] Dockerfile: Fixed the 'ENTRYPOINT' as it needed the ./ prefix Also added entry to the CHANGELOG and updated the README with this new feature --- CHANGELOG.md | 2 ++ Dockerfile | 4 ++-- README.md | 18 +++++++++++++----- 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8695273..463f974 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,8 @@ - New flag `--description-file` to generate a description file of the Graph Nodes ([Issue #178](https://github.com/cycloidio/inframap/issues/178)) +- `graphviz` is now in the Docker image so no need of external tools to generate the graph by [@agalazis](https://github.com/agalazis) + ([PR #221](https://github.com/cycloidio/inframap/pull/221)) ### Changed diff --git a/Dockerfile b/Dockerfile index 290d681..99fa34d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -12,7 +12,7 @@ RUN apk -q --no-progress add git make \ FROM alpine -RUN apk -q --no-progress add graphviz ttf-dejavu\ +RUN apk -q --no-progress add graphviz ttf-dejavu \ && addgroup -g 1000 inframap \ && adduser -u 1000 -G inframap -s /bin/ash -D inframap @@ -22,4 +22,4 @@ WORKDIR /home/inframap COPY --from=builder /app/inframap /home/inframap -ENTRYPOINT ["inframap"] +ENTRYPOINT ["./inframap"] diff --git a/README.md b/README.md index 6ad136b..bee9958 100644 --- a/README.md +++ b/README.md @@ -81,33 +81,41 @@ The most important subcommands are: Visualizing with [dot](https://graphviz.org/download/) ```shell -$ inframap generate state.tfstate | dot -Tpng > graph.png +inframap generate state.tfstate | dot -Tpng > graph.png ``` or from the terminal itself with [graph-easy](https://github.com/ironcamel/Graph-Easy) ```shell -$ inframap generate state.tfstate | graph-easy +inframap generate state.tfstate | graph-easy ``` or from HCL ```shell -$ inframap generate config.tf | graph-easy +inframap generate config.tf | graph-easy ``` or HCL module ```shell -$ inframap generate ./my-module/ | graph-easy +inframap generate ./my-module/ | graph-easy ``` using docker image (assuming that your Terraform files are in the working directory) ```shell -$ docker run --rm -v ${PWD}:/opt cycloid/inframap generate /opt/terraform.tfstate +docker run --rm -v ${PWD}:/opt cycloid/inframap generate /opt/terraform.tfstate ``` +or if you use docker and want to have the images generated already, the docker image has the `graphviz` lib installed: + +```shell +docker run --rm -v ${PWD}:/opt --entrypoint "/bin/ash" inframap -c './inframap generate /opt/PATH_TO_HCL_STATE | dot -Tpng > /opt/graph.png' +``` + +and the generated image will be on `$PWD/graph.png` + **Note:** InfraMap will guess the type of the input (HCL or TFState) by validating if it's a JSON and if it fails then we fallback to HCL (except if you send a directory on args, the it'll use HCL directly), to force one specific type you can use `--hcl` or `--tfstate` flags.