Skip to content

Commit 1ad85f1

Browse files
author
Steve Scaffidi
committed
Enable building the NPD in a docker container
This has several benefits. For example, now I can develop and build linux binaries of the NPD on my mac. Also other devs don't need to make sure they have the systemd headers installed.
1 parent 9bb87cd commit 1ad85f1

File tree

2 files changed

+34
-2
lines changed

2 files changed

+34
-2
lines changed

Makefile

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ IMAGE:=$(REGISTRY)/node-problem-detector:$(TAG)
4646

4747
# ENABLE_JOURNALD enables build journald support or not. Building journald support needs libsystemd-dev
4848
# or libsystemd-journal-dev.
49-
# TODO(random-liu): Build NPD inside container.
5049
ENABLE_JOURNALD?=1
5150

5251
# TODO(random-liu): Support different architectures.
@@ -93,7 +92,9 @@ Dockerfile: Dockerfile.in
9392
test: vet fmt
9493
go test -timeout=1m -v -race ./cmd/options ./pkg/... $(BUILD_TAGS)
9594

96-
build-container: ./bin/node-problem-detector ./bin/log-counter Dockerfile
95+
build-binaries: ./bin/node-problem-detector ./bin/log-counter
96+
97+
build-container: build-binaries Dockerfile
9798
docker build -t $(IMAGE) .
9899

99100
build-tar: ./bin/node-problem-detector ./bin/log-counter
@@ -103,6 +104,12 @@ build-tar: ./bin/node-problem-detector ./bin/log-counter
103104

104105
build: build-container build-tar
105106

107+
docker-builder:
108+
docker build -t npd-builder ./builder
109+
110+
build-in-docker: clean docker-builder
111+
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'
112+
106113
push-container: build-container
107114
gcloud docker -- push $(IMAGE)
108115

builder/Dockerfile

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Copyright 2017 The Kubernetes Authors. All rights reserved
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
FROM golang:1.10.2
16+
LABEL maintainer="Marcin Wielgus <[email protected]>"
17+
18+
ENV GOPATH /gopath/
19+
ENV PATH $GOPATH/bin:$PATH
20+
21+
RUN apt-get update && apt-get --yes install libsystemd-dev
22+
RUN go version
23+
RUN go get github.com/tools/godep
24+
RUN godep version
25+
CMD ["/bin/bash"]

0 commit comments

Comments
 (0)