Use prebuilt container with jsonnet in it

This commit is contained in:
paulfantom
2019-05-14 13:03:15 +02:00
parent ff9fb35e04
commit 5fe3df56be
2 changed files with 11 additions and 41 deletions

View File

@@ -2,25 +2,19 @@ JSONNET_FMT := jsonnet fmt -n 2 --max-blank-lines 2 --string-style s --comment-s
JB_BINARY:=$(GOPATH)/bin/jb JB_BINARY:=$(GOPATH)/bin/jb
EMBEDMD_BINARY:=$(GOPATH)/bin/embedmd EMBEDMD_BINARY:=$(GOPATH)/bin/embedmd
CONTAINER_CMD:=docker run --rm \
-u="$(shell id -u):$(shell id -g)" \
-v "$(shell go env GOCACHE):/.cache/go-build" \
-v "$(PWD):/go/src/github.com/coreos/kube-prometheus:Z" \
-w "/go/src/github.com/coreos/kube-prometheus" \
quay.io/coreos/jsonnet-ci
all: generate fmt test all: generate fmt test
hack/jsonnet-docker-image: scripts/jsonnet/Dockerfile .PHONY: generate-in-docker
# Create empty target file, for the sole purpose of recording when this target generate-in-docker:
# was last executed via the last-modification timestamp on the file. See
# https://www.gnu.org/software/make/manual/make.html#Empty-Targets
docker build -f - -t po-jsonnet . < scripts/jsonnet/Dockerfile
touch $@
generate-in-docker: hack/jsonnet-docker-image
@echo ">> Compiling assets and generating Kubernetes manifests" @echo ">> Compiling assets and generating Kubernetes manifests"
docker run \ $(CONTAINER_CMD) $(MAKE) $(MFLAGS) generate
--rm \
-u=$(shell id -u $(USER)):$(shell id -g $(USER)) \
-v $$PWD:/go/src/github.com/coreos/kube-prometheus/ \
-v $(shell go env GOCACHE):/.cache/go-build \
--workdir /go/src/github.com/coreos/kube-prometheus \
po-jsonnet make generate
generate: manifests **.md generate: manifests **.md
@@ -46,15 +40,9 @@ test: $(JB_BINARY)
test-e2e: test-e2e:
go test -timeout 55m -v ./tests/e2e -count=1 go test -timeout 55m -v ./tests/e2e -count=1
test-in-docker: hack/jsonnet-docker-image test-in-docker:
@echo ">> Compiling assets and generating Kubernetes manifests" @echo ">> Compiling assets and generating Kubernetes manifests"
docker run \ $(CONTAINER_CMD) $(MAKE) $(MFLAGS) test
--rm \
-u=$(shell id -u $(USER)):$(shell id -g $(USER)) \
-v $$PWD:/go/src/github.com/coreos/kube-prometheus/ \
-v $(shell go env GOCACHE):/.cache/go-build \
--workdir /go/src/github.com/coreos/kube-prometheus \
po-jsonnet make test
$(JB_BINARY): $(JB_BINARY):
go get -u github.com/jsonnet-bundler/jsonnet-bundler/cmd/jb go get -u github.com/jsonnet-bundler/jsonnet-bundler/cmd/jb

View File

@@ -1,18 +0,0 @@
FROM golang:1.12-stretch
ENV JSONNET_VERSION 0.12.1
RUN apt-get update -y && apt-get install -y jq && rm -rf /var/lib/apt/lists/*
RUN curl -Lso - https://github.com/google/jsonnet/archive/v${JSONNET_VERSION}.tar.gz | \
tar xfz - -C /tmp && \
cd /tmp/jsonnet-${JSONNET_VERSION} && \
make && mv jsonnet /usr/local/bin && \
rm -rf /tmp/jsonnet-${JSONNET_VERSION}
RUN go get github.com/brancz/gojsontoyaml
RUN go get github.com/campoy/embedmd
RUN go get github.com/jsonnet-bundler/jsonnet-bundler/cmd/jb
RUN mkdir -p /go/src/github.com/coreos/kube-prometheus
WORKDIR /go/src/github.com/coreos/kube-prometheus
RUN chmod -R 777 /go