diff --git a/Dockerfile b/Dockerfile index 44be80e..cc30d4a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -37,6 +37,12 @@ RUN make build # Package binary & certs in a scratch container FROM scratch + +# Setup DataDog source code linking +ARG GIT_REVISION +ENV DD_GIT_REPOSITORY_URL="github.com/Nextdoor/pg-bifrost" +ENV DD_GIT_COMMIT_SHA=${GIT_REVISION} + COPY --from=certs /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt COPY --from=intermediate /perf /perf COPY --from=intermediate /go/src/github.com/Nextdoor/pg-bifrost.git/target/pg-bifrost / diff --git a/Makefile b/Makefile index f3d2a57..1ca2815 100644 --- a/Makefile +++ b/Makefile @@ -2,12 +2,13 @@ GO_LDFLAGS ?= -w -extldflags "-static" +GIT_REVISION_SHORT := $(shell git rev-parse --short HEAD) GIT_REVISION := $(shell git rev-parse --short HEAD) GIT_TAG_VERSION := $(shell git tag -l --points-at HEAD | grep -v latest) ifeq ($(CI),true) GO_TEST_EXTRAS ?= "-coverprofile=c.out" - GO_LDFLAGS += -X main.GitRevision=$(GIT_REVISION) -X main.Version=$(GIT_TAG_VERSION) + GO_LDFLAGS += -X main.GitRevision=$(GIT_REVISION_SHORT) -X main.Version=$(GIT_TAG_VERSION) GO_PGOFLAGS ?= "-pgo=profiles/merged.pprof" endif @@ -65,7 +66,7 @@ DOCKER := $(shell which docker) docker_build: @echo "Building pg-bifrost docker image" - @$(DOCKER) build -t "pg-bifrost:latest" --build-arg is_ci="${CI}" . + @$(DOCKER) build -t "pg-bifrost:latest" --build-arg is_ci="${CI}" --build-arg GIT_REVISION="${GIT_REVISION}" . docker_get_binary: @echo "Copying binary from docker image"