diff --git a/Makefile b/Makefile index 67a1399c..43ef6ec5 100644 --- a/Makefile +++ b/Makefile @@ -14,7 +14,8 @@ # Build the node-problem-detector image. -.PHONY: all build-container build-tar build push-container push-tar push clean vet fmt version Dockerfile +.PHONY: all build-container build-tar build push-container push-tar push clean vet fmt version \ + Dockerfile build-binaries docker-builder build-in-docker all: build @@ -46,7 +47,6 @@ IMAGE:=$(REGISTRY)/node-problem-detector:$(TAG) # ENABLE_JOURNALD enables build journald support or not. Building journald support needs libsystemd-dev # or libsystemd-journal-dev. -# TODO(random-liu): Build NPD inside container. ENABLE_JOURNALD?=1 # TODO(random-liu): Support different architectures. @@ -93,7 +93,9 @@ Dockerfile: Dockerfile.in test: vet fmt go test -timeout=1m -v -race ./cmd/options ./pkg/... $(BUILD_TAGS) -build-container: ./bin/node-problem-detector ./bin/log-counter Dockerfile +build-binaries: ./bin/node-problem-detector ./bin/log-counter + +build-container: build-binaries Dockerfile docker build -t $(IMAGE) . build-tar: ./bin/node-problem-detector ./bin/log-counter @@ -103,6 +105,12 @@ build-tar: ./bin/node-problem-detector ./bin/log-counter build: build-container build-tar +docker-builder: + docker build -t npd-builder ./builder + +build-in-docker: clean docker-builder + docker run -v `pwd`:/gopath/src/k8s.io/node-problem-detector/ npd-builder:latest bash -c 'cd /gopath/src/k8s.io/node-problem-detector/ && make build-binaries' + push-container: build-container gcloud docker -- push $(IMAGE) diff --git a/builder/Dockerfile b/builder/Dockerfile new file mode 100644 index 00000000..7f9279ff --- /dev/null +++ b/builder/Dockerfile @@ -0,0 +1,25 @@ +# Copyright 2018 The Kubernetes Authors. All rights reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +FROM golang:1.11.0 +LABEL maintainer="Andy Xie " + +ENV GOPATH /gopath/ +ENV PATH $GOPATH/bin:$PATH + +RUN apt-get update && apt-get --yes install libsystemd-dev +RUN go version +RUN go get github.com/tools/godep +RUN godep version +CMD ["/bin/bash"]