Skip to content

Commit aadb16b

Browse files
committed
Remove Dockerfile.in rewrite hack and use updated arg in Dockerfile
1 parent 8f2a94f commit aadb16b

File tree

3 files changed

+15
-17
lines changed

3 files changed

+15
-17
lines changed

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
/bin/
2-
/Dockerfile
32
/test/bin/
43
/*.tar.gz
54
ci.env

Dockerfile.in renamed to Dockerfile

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,20 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
FROM @BASEIMAGE@
15+
ARG BASEIMAGE
16+
FROM ${BASEIMAGE}
17+
1618
MAINTAINER Random Liu <[email protected]>
1719

1820
RUN clean-install util-linux libsystemd0 bash
1921

2022
# Avoid symlink of /etc/localtime.
2123
RUN test -h /etc/localtime && rm -f /etc/localtime && cp /usr/share/zoneinfo/UTC /etc/localtime || true
2224

23-
ADD ./bin/node-problem-detector /node-problem-detector
24-
ADD ./bin/health-checker /home/kubernetes/bin/health-checker
25+
COPY ./bin/node-problem-detector /node-problem-detector
2526

26-
# Below command depends on ENABLE_JOURNAL=1.
27-
ADD ./bin/log-counter /home/kubernetes/bin/log-counter
27+
ARG LOGCOUNTER
28+
COPY ./bin/health-checker ${LOGCOUNTER} /home/kubernetes/bin/
2829

29-
ADD config /config
30-
ENTRYPOINT ["/node-problem-detector", "--system-log-monitors=/config/kernel-monitor.json"]
30+
COPY config /config
31+
ENTRYPOINT ["/node-problem-detector", "--config.system-log-monitor=/config/kernel-monitor.json"]

Makefile

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ CGO_ENABLED:=0
6464

6565
# Construct the "-tags" parameter used by "go build".
6666
BUILD_TAGS?=
67+
6768
ifeq ($(ENABLE_JOURNALD), 1)
6869
# Enable journald build tag.
6970
BUILD_TAGS:=$(BUILD_TAGS) journald
@@ -73,6 +74,11 @@ ifeq ($(ENABLE_JOURNALD), 1)
7374
# here, because go-systemd uses dlopen, and dlopen will not work properly in a
7475
# statically linked application.
7576
CGO_ENABLED:=1
77+
LOGCOUNTER=./bin/log-counter
78+
else
79+
# Hack: Don't copy over log-counter, use a wildcard path that shouldnt match
80+
# anything in COPY command.
81+
LOGCOUNTER=*dont-include-log-counter
7682
endif
7783

7884
vet:
@@ -175,14 +181,6 @@ endif
175181
-tags "$(BUILD_TAGS)" \
176182
cmd/healthchecker/health_checker.go
177183

178-
Dockerfile: Dockerfile.in
179-
sed -e 's|@BASEIMAGE@|$(BASEIMAGE)|g' $< >$@
180-
ifneq ($(ENABLE_JOURNALD), 1)
181-
sed -i '/Below command depends on ENABLE_JOURNAL=1/,+2d' $@
182-
echo "Warning: log-counter requires journald, skipping."
183-
endif
184-
185-
186184
test: vet fmt
187185
GO111MODULE=on go test -mod vendor -timeout=1m -v -race -short -tags "$(BUILD_TAGS)" ./...
188186

@@ -199,7 +197,7 @@ e2e-test: vet fmt build-tar
199197
build-binaries: ./bin/node-problem-detector ./bin/log-counter ./bin/health-checker
200198

201199
build-container: build-binaries Dockerfile
202-
docker build -t $(IMAGE) .
200+
docker build -t $(IMAGE) --build-arg BASEIMAGE=$(BASEIMAGE) --build-arg LOGCOUNTER=$(LOGCOUNTER) .
203201

204202
build-tar: ./bin/node-problem-detector ./bin/log-counter ./bin/health-checker ./test/bin/problem-maker
205203
tar -zcvf $(TARBALL) bin/ config/ test/e2e-install.sh test/bin/problem-maker

0 commit comments

Comments
 (0)