From aadb16b3d4601abce7ada0721fceec07e125cd70 Mon Sep 17 00:00:00 2001 From: Jeremy Edwards <1312331+jeremyje@users.noreply.github.com> Date: Sat, 5 Dec 2020 22:34:16 +0000 Subject: [PATCH] Remove Dockerfile.in rewrite hack and use updated arg in Dockerfile --- .gitignore | 1 - Dockerfile.in => Dockerfile | 15 ++++++++------- Makefile | 16 +++++++--------- 3 files changed, 15 insertions(+), 17 deletions(-) rename Dockerfile.in => Dockerfile (71%) diff --git a/.gitignore b/.gitignore index abeffe71..2011f76d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,4 @@ /bin/ -/Dockerfile /test/bin/ /*.tar.gz ci.env diff --git a/Dockerfile.in b/Dockerfile similarity index 71% rename from Dockerfile.in rename to Dockerfile index def0f839..7ec0591d 100644 --- a/Dockerfile.in +++ b/Dockerfile @@ -12,7 +12,9 @@ # See the License for the specific language governing permissions and # limitations under the License. -FROM @BASEIMAGE@ +ARG BASEIMAGE +FROM ${BASEIMAGE} + MAINTAINER Random Liu RUN clean-install util-linux libsystemd0 bash @@ -20,11 +22,10 @@ RUN clean-install util-linux libsystemd0 bash # Avoid symlink of /etc/localtime. RUN test -h /etc/localtime && rm -f /etc/localtime && cp /usr/share/zoneinfo/UTC /etc/localtime || true -ADD ./bin/node-problem-detector /node-problem-detector -ADD ./bin/health-checker /home/kubernetes/bin/health-checker +COPY ./bin/node-problem-detector /node-problem-detector -# Below command depends on ENABLE_JOURNAL=1. -ADD ./bin/log-counter /home/kubernetes/bin/log-counter +ARG LOGCOUNTER +COPY ./bin/health-checker ${LOGCOUNTER} /home/kubernetes/bin/ -ADD config /config -ENTRYPOINT ["/node-problem-detector", "--system-log-monitors=/config/kernel-monitor.json"] +COPY config /config +ENTRYPOINT ["/node-problem-detector", "--config.system-log-monitor=/config/kernel-monitor.json"] diff --git a/Makefile b/Makefile index 27afad82..74c0d039 100644 --- a/Makefile +++ b/Makefile @@ -64,6 +64,7 @@ CGO_ENABLED:=0 # Construct the "-tags" parameter used by "go build". BUILD_TAGS?= + ifeq ($(ENABLE_JOURNALD), 1) # Enable journald build tag. BUILD_TAGS:=$(BUILD_TAGS) journald @@ -73,6 +74,11 @@ ifeq ($(ENABLE_JOURNALD), 1) # here, because go-systemd uses dlopen, and dlopen will not work properly in a # statically linked application. CGO_ENABLED:=1 + LOGCOUNTER=./bin/log-counter +else + # Hack: Don't copy over log-counter, use a wildcard path that shouldnt match + # anything in COPY command. + LOGCOUNTER=*dont-include-log-counter endif vet: @@ -175,14 +181,6 @@ endif -tags "$(BUILD_TAGS)" \ cmd/healthchecker/health_checker.go -Dockerfile: Dockerfile.in - sed -e 's|@BASEIMAGE@|$(BASEIMAGE)|g' $< >$@ -ifneq ($(ENABLE_JOURNALD), 1) - sed -i '/Below command depends on ENABLE_JOURNAL=1/,+2d' $@ - echo "Warning: log-counter requires journald, skipping." -endif - - test: vet fmt GO111MODULE=on go test -mod vendor -timeout=1m -v -race -short -tags "$(BUILD_TAGS)" ./... @@ -199,7 +197,7 @@ e2e-test: vet fmt build-tar build-binaries: ./bin/node-problem-detector ./bin/log-counter ./bin/health-checker build-container: build-binaries Dockerfile - docker build -t $(IMAGE) . + docker build -t $(IMAGE) --build-arg BASEIMAGE=$(BASEIMAGE) --build-arg LOGCOUNTER=$(LOGCOUNTER) . build-tar: ./bin/node-problem-detector ./bin/log-counter ./bin/health-checker ./test/bin/problem-maker tar -zcvf $(TARBALL) bin/ config/ test/e2e-install.sh test/bin/problem-maker