From 8b06eb66bf0651118e2bce68609e104f208fa15e Mon Sep 17 00:00:00 2001 From: Robert Fratto Date: Mon, 15 Jul 2019 15:04:43 -0400 Subject: [PATCH] Rollback changes to Makefile and build/Dockerfile from #730 (#758) This commit rolls back the changes to the Makefile and build/Dockerfile that caused CGO_ENABLED=1 to be present during some builds. This commit causes the journal support to be disabled in any build produced by make. Journal support can still be enabled in a manual build: go build -o cmd/promtail/promtail cmd/promtail --- Makefile | 5 ++--- build/Dockerfile | 4 ++-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index 54ff6a7f29..9fa45ebb43 100644 --- a/Makefile +++ b/Makefile @@ -104,7 +104,6 @@ loki-build-image/$(UPTODATE): loki-build-image/* # All the boiler plate for building golang follows: SUDO := $(shell docker info >/dev/null 2>&1 || echo "sudo -E") BUILD_IN_CONTAINER := true -CGO_ENABLED := 0 # RM is parameterized to allow CircleCI to run builds, as it # currently disallows `docker run --rm`. This value is overridden # in circle.yml @@ -150,13 +149,13 @@ $(EXES) $(DEBUG_EXES) $(PROTO_GOS) $(YACC_GOS) lint test shell check-generated-f else $(DEBUG_EXES): loki-build-image/$(UPTODATE) - CGO_ENABLED=$(CGO_ENABLED) go build $(DEBUG_GO_FLAGS) -o $@ ./$(@D) + CGO_ENABLED=0 go build $(DEBUG_GO_FLAGS) -o $@ ./$(@D) $(NETGO_CHECK) # Copy the delve binary to make it easily available to put in the binary's container. [ -f "/go/bin/dlv" ] && mv "/go/bin/dlv" $(@D)/dlv $(EXES): loki-build-image/$(UPTODATE) - CGO_ENABLED=$(CGO_ENABLED) go build $(GO_FLAGS) -o $@ ./$(@D) + CGO_ENABLED=0 go build $(GO_FLAGS) -o $@ ./$(@D) $(NETGO_CHECK) %.pb.go: loki-build-image/$(UPTODATE) diff --git a/build/Dockerfile b/build/Dockerfile index 7d6e92749d..72c6a9baf8 100644 --- a/build/Dockerfile +++ b/build/Dockerfile @@ -17,7 +17,7 @@ RUN touch loki-build-image/.uptodate &&\ # production image FROM golang as builder-production ARG APP -RUN make CGO_ENABLED=1 BUILD_IN_CONTAINER=false cmd/${APP}/${APP} &&\ +RUN make BUILD_IN_CONTAINER=false cmd/${APP}/${APP} &&\ mv cmd/${APP}/${APP} /build/${APP} FROM scratch as production @@ -28,7 +28,7 @@ COPY --from=builder-production /build/${APP} /usr/bin/${APP} FROM golang as builder-debug ARG APP RUN go get github.com/go-delve/delve/cmd/dlv &&\ - make CGO_ENBALED=1 BUILD_IN_CONTAINER=false cmd/promtail/promtail-debug &&\ + make BUILD_IN_CONTAINER=false cmd/promtail/promtail-debug &&\ mv cmd/${APP}/${APP}-debug /build/app-debug &&\ mv cmd/${APP}/dlv /build/dlv