From 5a34dc388de1848460ed05a72d06356bc4f0d4ad Mon Sep 17 00:00:00 2001 From: Sandeep Sukhani Date: Tue, 4 Aug 2020 10:50:58 +0530 Subject: [PATCH] add support for building querytee --- Makefile | 17 +++++++++++++++++ cmd/querytee/Dockerfile | 11 +++++++++++ cmd/querytee/Dockerfile.cross | 18 ++++++++++++++++++ 3 files changed, 46 insertions(+) create mode 100644 cmd/querytee/Dockerfile create mode 100644 cmd/querytee/Dockerfile.cross diff --git a/Makefile b/Makefile index 34fb516473ed..276334bb7f08 100644 --- a/Makefile +++ b/Makefile @@ -182,6 +182,14 @@ cmd/loki-canary/loki-canary: $(APP_GO_FILES) cmd/loki-canary/main.go CGO_ENABLED=0 go build $(GO_FLAGS) -o $@ ./$(@D) $(NETGO_CHECK) +################# +# Loki-QueryTee # +################# + +loki-querytee: $(APP_GO_FILES) cmd/querytee/main.go + CGO_ENABLED=0 go build $(GO_FLAGS) -o ./cmd/querytee/$@ ./cmd/querytee/ + $(NETGO_CHECK) + ############ # Promtail # ############ @@ -260,6 +268,7 @@ clean: rm -rf cmd/loki/loki rm -rf cmd/logcli/logcli rm -rf cmd/loki-canary/loki-canary + rm -rf cmd/querytee/querytee rm -rf .cache rm -rf cmd/docker-driver/rootfs rm -rf dist/ @@ -535,6 +544,14 @@ loki-canary-image-cross: loki-canary-push: loki-canary-image-cross $(SUDO) $(PUSH_OCI) $(IMAGE_PREFIX)/loki-canary:$(IMAGE_TAG) +# loki-querytee +loki-querytee-image: + $(SUDO) docker build -t $(IMAGE_PREFIX)/loki-querytee:$(IMAGE_TAG) -f cmd/querytee/Dockerfile . +loki-querytee-image-cross: + $(SUDO) $(BUILD_OCI) -t $(IMAGE_PREFIX)/loki-querytee:$(IMAGE_TAG) -f cmd/querytee/Dockerfile.cross . +loki-querytee-push: loki-querytee-image-cross + $(SUDO) $(PUSH_OCI) $(IMAGE_PREFIX)/loki-querytee:$(IMAGE_TAG) + # build-image (only amd64) build-image: OCI_PLATFORMS= build-image: diff --git a/cmd/querytee/Dockerfile b/cmd/querytee/Dockerfile new file mode 100644 index 000000000000..21347452156e --- /dev/null +++ b/cmd/querytee/Dockerfile @@ -0,0 +1,11 @@ +FROM golang:1.14.2 as build + +ARG TOUCH_PROTOS +COPY . /src/loki +WORKDIR /src/loki +RUN make clean && make BUILD_IN_CONTAINER=false loki-querytee + +FROM alpine:3.9 +RUN apk add --update --no-cache ca-certificates +COPY --from=build /src/loki/cmd/querytee/loki-querytee /usr/bin/querytee +ENTRYPOINT [ "/usr/bin/querytee" ] diff --git a/cmd/querytee/Dockerfile.cross b/cmd/querytee/Dockerfile.cross new file mode 100644 index 000000000000..e788c7537b31 --- /dev/null +++ b/cmd/querytee/Dockerfile.cross @@ -0,0 +1,18 @@ +ARG BUILD_IMAGE=grafana/loki-build-image:0.9.1 +# Directories in this file are referenced from the root of the project not this folder +# This file is intended to be called from the root like so: +# docker build -t grafana/promtail -f cmd/promtail/Dockerfile . +FROM golang:1.11.4-alpine as goenv +RUN go env GOARCH > /goarch && \ + go env GOARM > /goarm + +FROM --platform=linux/amd64 $BUILD_IMAGE as build +COPY --from=goenv /goarch /goarm / +COPY . /src/loki +WORKDIR /src/loki +RUN make clean && GOARCH=$(cat /goarch) GOARM=$(cat /goarm) make BUILD_IN_CONTAINER=false loki-querytee + +FROM alpine:3.9 +RUN apk add --update --no-cache ca-certificates +COPY --from=build /src/loki/cmd/querytee/querytee /usr/bin/querytee +ENTRYPOINT [ "/usr/bin/querytee" ]