diff --git a/Makefile b/Makefile index 86ebbcc84d0150a23707a8f361e4e78066de5e88..bc6ded2dd46432310ad7494aee754020e6dd5520 100644 --- a/Makefile +++ b/Makefile @@ -2,25 +2,19 @@ JSONNET_FMT := jsonnet fmt -n 2 --max-blank-lines 2 --string-style s --comment-s JB_BINARY:=$(GOPATH)/bin/jb 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 -hack/jsonnet-docker-image: scripts/jsonnet/Dockerfile -# Create empty target file, for the sole purpose of recording when this target -# 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 +.PHONY: generate-in-docker +generate-in-docker: @echo ">> Compiling assets and generating Kubernetes manifests" - docker run \ - --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 + $(CONTAINER_CMD) $(MAKE) $(MFLAGS) generate generate: manifests **.md @@ -46,15 +40,9 @@ test: $(JB_BINARY) test-e2e: 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" - docker run \ - --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 + $(CONTAINER_CMD) $(MAKE) $(MFLAGS) test $(JB_BINARY): go get -u github.com/jsonnet-bundler/jsonnet-bundler/cmd/jb diff --git a/scripts/jsonnet/Dockerfile b/scripts/jsonnet/Dockerfile deleted file mode 100644 index bf68d6fd25f6530ec0116c758d03b64ff081e591..0000000000000000000000000000000000000000 --- a/scripts/jsonnet/Dockerfile +++ /dev/null @@ -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