From bb8404698f8176b34dc445e612f16d09efcc6a59 Mon Sep 17 00:00:00 2001 From: Udit Gaurav <35391335+uditgaurav@users.noreply.github.com> Date: Mon, 23 Nov 2020 11:01:11 +0530 Subject: [PATCH] chore(): Fix Dockerfile CMD to take variables (#77) Signed-off-by: Udit Gaurav --- Dockerfile | 9 +++------ Makefile | 16 ++++++++++++++++ 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/Dockerfile b/Dockerfile index c55ffac7..0e9214ec 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,16 +1,13 @@ FROM ubuntu:16.04 ARG TARGETARCH +ENV EXPORTER=/exporter-${TARGETARCH} RUN apt-get update && apt-get install -y ca-certificates && rm -rf /var/cache/apk/* -COPY ./exporter-${TARGETARCH} / +COPY .$EXPORTER / EXPOSE 8080 -CMD ["/exporter-${TARGETARCH}"] - - - - +CMD ["sh", "-c","$EXPORTER"] diff --git a/Makefile b/Makefile index 4795a418..75d2b943 100644 --- a/Makefile +++ b/Makefile @@ -1,3 +1,4 @@ + # Makefile for building Chaos Exporter # Reference Guide - https://www.gnu.org/software/make/manual/make.html @@ -118,3 +119,18 @@ unused-package-check: if [ -n "$${tidy}" ]; then \ echo "go mod tidy checking failed!"; echo "$${tidy}"; echo; \ fi + +.PHONY: build-amd64 +build-amd64: + @echo "-------------------------" + @echo "--> Build chaos-exporter image" + @echo "-------------------------" + @sudo docker build --file Dockerfile --tag $(DOCKER_REPO)/$(DOCKER_IMAGE):$(DOCKER_TAG) . --build-arg TARGETARCH=amd64 + +.PHONY: push-amd64 +push-amd64: + + @echo "------------------------------" + @echo "--> Pushing image" + @echo "------------------------------" + @sudo docker push $(DOCKER_REPO)/$(DOCKER_IMAGE):$(DOCKER_TAG)