Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Bundle grpahViz and use non root user #221

Merged
merged 3 commits into from
Aug 28, 2023
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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
19 changes: 14 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
FROM golang:1.16.5-alpine3.12 as builder

WORKDIR /app

COPY go.mod go.sum ./
Expand All @@ -8,9 +7,19 @@ RUN go mod download

COPY . .

RUN apk -q --no-progress add git make; \
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"]
18 changes: 13 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down