File tree Expand file tree Collapse file tree 3 files changed +90
-0
lines changed Expand file tree Collapse file tree 3 files changed +90
-0
lines changed Original file line number Diff line number Diff line change 5151 git status --porcelain
5252 exit 1
5353 fi
54+
55+ container_build :
56+ name : " build container image"
57+ runs-on : ubuntu-latest
58+
59+ steps :
60+ - name : " Fetch source code"
61+ uses : actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
62+ - name : " Build container image"
63+ run : |
64+ docker build --output type=docker -t terraform-config-inspect:ci-${{ github.run_id }}-${{ github.run_number }} -f build/Dockerfile .
Original file line number Diff line number Diff line change @@ -139,6 +139,20 @@ $ terraform-config-inspect --json path/to/module
139139}
140140```
141141
142+ ## Containarized
143+
144+ One can build a container version of this application with the following
145+ oneliner:
146+ ` docker build -t terraform-config-inspect:latest -f build/Dockerfile . `
147+
148+ Feel free to use our development stage to debug or when contributen to this
149+ project by including the ` --target dev ` in the container build phase.
150+
151+ Example:
152+ - How to use the generated image if you current context is the module you want
153+ to analyize:
154+ ` docker run -it -v $(pwd):/$(pwd) -w $(pwd) terraform-config-inspect:latest `
155+
142156## Contributing
143157
144158This library and tool are intentionally focused on only extracting simple
Original file line number Diff line number Diff line change 1+ ARG BUILD_GO_IMAGE=golang:1.18-alpine
2+ ARG LIVE_GO_IMAGE=scratch
3+
4+ # ##
5+ # ## Setup
6+ # ##
7+
8+ # ## Setup Build
9+ FROM ${BUILD_GO_IMAGE} AS setup-build
10+
11+ ARG GOARCH
12+ ARG GOOS=linux
13+
14+ ENV GOARCH=${GOARCH}
15+ ENV GOBIN=${GOPATH}/bin
16+ ENV GOOS=${GOOS}
17+
18+ WORKDIR /usr/local/src
19+
20+ # Ease the debugging and development build by adding the go
21+ # installed binaries to the PATH
22+ ENV PATH=${PATH}:${GOBIN}
23+
24+ # Copy go.mod and go.sum files seperatly to allow caching
25+ # of dependencies
26+ COPY go.* ./
27+ # Download dependencies
28+ RUN go mod download
29+
30+ COPY . .
31+
32+ # ## Setup Live Image
33+ FROM ${LIVE_GO_IMAGE} AS setup-live
34+
35+ COPY --from=setup-build /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
36+
37+ # ##
38+ # ## Build
39+ # ##
40+ FROM setup-build AS build
41+
42+ # Build the application binary
43+ RUN CGO_ENABLED=0 GOOS=${GOOS} GOARCH=${GOARCH} go build -o ${GOBIN}/terraform-config-inspect .
44+
45+ # ##
46+ # ## Final Images
47+ # ##
48+
49+ # ## Dev
50+ # This stage is used for development and debugging purposes,
51+ # but it can also be used for CI-related tasks, and others.
52+ FROM setup-build AS dev
53+
54+ # Install delve debugger (the delve version shouldn't be a concern 🤷♂️)
55+ RUN go install github.com/go-delve/delve/cmd/dlv@latest
56+
57+ # Explicitly not overriding the entrypoint of the source image
58+ # ENTRYPOINT [ "" ]
59+
60+ # ## Live
61+ FROM setup-live AS live
62+
63+ COPY --from=build /go/bin/terraform-config-inspect /
64+
65+ ENTRYPOINT ["/terraform-config-inspect" ]
You can’t perform that action at this time.
0 commit comments