Skip to content

Commit

Permalink
Formal docker images for conftest
Browse files Browse the repository at this point in the history
The makefile is required as goreleaser is fairly limited about what it can do with images.
The examples images should make demos easier, as it includes all of the
required tools to run the existing set of demos.
  • Loading branch information
garethr committed May 17, 2019
1 parent 8ca4397 commit 0d13e50
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 1 deletion.
30 changes: 29 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,36 @@ WORKDIR /
COPY . /
RUN go build .


FROM bats/bats:v1.1.0 as acceptance
COPY --from=builder /conftest /usr/local/bin
COPY acceptance.bats /acceptance.bats
COPY testdata /testdata
COPY examples /examples
RUN ./acceptance.bats


FROM golang:1.12-alpine as examples

ENV TERRAFORM_VERSION=0.12.0-rc1 \
KUSTOMIZE_VERSION=2.0.3

COPY --from=builder /conftest /usr/local/bin
COPY examples /examples

RUN apk add --update npm make git jq ca-certificates openssl unzip wget && \
cd /tmp && \
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


FROM scratch
COPY --from=builder /conftest /
ENTRYPOINT ["/conftest"]
CMD ["--help"]
28 changes: 28 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@

TAG=$(shell git describe --abbrev=0 --tags)

NAME=conftest
IMAGE=instrumenta/$(NAME)

COMMAND=docker
BUILD=DOCKER_BUILDKIT=1 $(COMMAND) build
PUSH=$(COMMAND) push

all: push

examples:
$(BUILD) --target examples -t instrumenta/conftest:examples .

acceptance:
$(BUILD) --target acceptance .

conftest:
$(BUILD) -t $(IMAGE):$(TAG) .
$(COMMAND) tag $(IMAGE):$(TAG) $(IMAGE):latest

push: example conftest
$(PUSH) $(IMAGE):$(TAG)
$(PUSH) $(IMAGE):latest
$(PUSH) $(IMAGE):examples

.PHONY: examples acceptance conftest push all

0 comments on commit 0d13e50

Please sign in to comment.