forked from open-policy-agent/conftest
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
66 lines (49 loc) · 1.61 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
FROM golang:1.16-alpine as base
ARG ARCH=amd64
ARG VERSION
ARG COMMIT
ARG DATE
ENV GOOS=linux \
CGO_ENABLED=0 \
GOARCH=${ARCH}
RUN apk add --no-cache git
WORKDIR /app
COPY go.mod .
COPY go.sum .
RUN go mod download
COPY . .
## BUILDER STAGE ##
FROM base as builder
RUN go build -o conftest -ldflags="-w -s -X github.com/open-policy-agent/conftest/internal/commands.version=${VERSION}" main.go
## TEST STAGE ##
FROM base as test
RUN go test -v ./...
## ACCEPTANCE STAGE ##
FROM base as acceptance
COPY --from=builder /app/conftest /app/conftest
RUN apk add --no-cache npm bash
RUN npm install -g bats
RUN bats acceptance.bats
## EXAMPLES STAGE ##
FROM base as examples
ENV TERRAFORM_VERSION=0.12.28 \
KUSTOMIZE_VERSION=2.0.3
COPY --from=builder /app/conftest /usr/local/bin
COPY examples /examples
WORKDIR /tmp
RUN apk add --no-cache npm make git jq ca-certificates openssl unzip wget && \
wget "https://releases.hashicorp.com/terraform/${TERRAFORM_VERSION}/terraform_${TERRAFORM_VERSION}_linux_amd64.zip" && \
unzip "terraform_${TERRAFORM_VERSION}_linux_amd64.zip" -d /usr/local/bin
RUN wget -O /usr/local/bin/kustomize "https://github.com/kubernetes-sigs/kustomize/releases/download/v${KUSTOMIZE_VERSION}/kustomize_${KUSTOMIZE_VERSION}_linux_amd64" && \
chmod +x /usr/local/bin/kustomize
RUN go get -u cuelang.org/go/cmd/cue
WORKDIR /examples
## RELEASE ##
FROM alpine:latest
# Install git for protocols that depend on it when using conftest pull
RUN apk add --no-cache git
COPY --from=builder /app/conftest /
RUN ln -s /conftest /usr/local/bin/conftest
WORKDIR /project
ENTRYPOINT ["/conftest"]
CMD ["--help"]