Skip to content

Commit f85b416

Browse files
authored
Merge pull request #204 from hercynium/build-in-docker
Enable building the NPD in a docker container
2 parents 9bb87cd + 2d77ebd commit f85b416

File tree

2 files changed

+36
-3
lines changed

2 files changed

+36
-3
lines changed

Makefile

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@
1414

1515
# Build the node-problem-detector image.
1616

17-
.PHONY: all build-container build-tar build push-container push-tar push clean vet fmt version Dockerfile
17+
.PHONY: all build-container build-tar build push-container push-tar push clean vet fmt version \
18+
Dockerfile build-binaries docker-builder build-in-docker
1819

1920
all: build
2021

@@ -46,7 +47,6 @@ IMAGE:=$(REGISTRY)/node-problem-detector:$(TAG)
4647

4748
# ENABLE_JOURNALD enables build journald support or not. Building journald support needs libsystemd-dev
4849
# or libsystemd-journal-dev.
49-
# TODO(random-liu): Build NPD inside container.
5050
ENABLE_JOURNALD?=1
5151

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

96-
build-container: ./bin/node-problem-detector ./bin/log-counter Dockerfile
96+
build-binaries: ./bin/node-problem-detector ./bin/log-counter
97+
98+
build-container: build-binaries Dockerfile
9799
docker build -t $(IMAGE) .
98100

99101
build-tar: ./bin/node-problem-detector ./bin/log-counter
@@ -103,6 +105,12 @@ build-tar: ./bin/node-problem-detector ./bin/log-counter
103105

104106
build: build-container build-tar
105107

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

builder/Dockerfile

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Copyright 2018 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.11.0
16+
LABEL maintainer="Andy Xie <[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)