Skip to content

Commit

Permalink
Rollback changes to Makefile and build/Dockerfile from grafana#730
Browse files Browse the repository at this point in the history
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
  • Loading branch information
rfratto committed Jul 15, 2019
1 parent 9eb3098 commit ad0c2b1
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
5 changes: 2 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions build/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand Down

0 comments on commit ad0c2b1

Please sign in to comment.