diff --git a/Makefile b/Makefile index c5afc7b669d64..2942a2409d13a 100644 --- a/Makefile +++ b/Makefile @@ -458,13 +458,17 @@ endif LOKI_DOCKER_DRIVER ?= "grafana/loki-docker-driver" PLUGIN_TAG ?= $(IMAGE_TAG) PLUGIN_ARCH ?= +PLUGIN_BUILD_ARGS ?= +ifeq ("$(PLUGIN_ARCH)", "-arm64") + PLUGIN_BUILD_ARGS = --build-arg GOARCH=arm64 +endif # build-rootfs # builds the plugin rootfs define build-rootfs rm -rf clients/cmd/docker-driver/rootfs || true mkdir clients/cmd/docker-driver/rootfs - docker build --build-arg $(BUILD_IMAGE) -t rootfsimage -f clients/cmd/docker-driver/Dockerfile . + docker build $(PLUGIN_BUILD_ARGS) --build-arg $(BUILD_IMAGE) -t rootfsimage -f clients/cmd/docker-driver/Dockerfile . ID=$$(docker create rootfsimage true) && \ (docker export $$ID | tar -x -C clients/cmd/docker-driver/rootfs) && \ @@ -481,7 +485,7 @@ docker-driver: docker-driver-clean ## build the docker-driver executable docker plugin create $(LOKI_DOCKER_DRIVER):main$(PLUGIN_ARCH) clients/cmd/docker-driver clients/cmd/docker-driver/docker-driver: - CGO_ENABLED=0 go build $(GO_FLAGS) -o $@ ./$(@D) + CGO_ENABLED=0 GOARCH=$(GOARCH) go build $(GO_FLAGS) -o $@ ./$(@D) docker-driver-push: docker-driver ifndef DOCKER_PASSWORD diff --git a/clients/cmd/docker-driver/Dockerfile b/clients/cmd/docker-driver/Dockerfile index 672556240f19b..b2a2ba8069857 100644 --- a/clients/cmd/docker-driver/Dockerfile +++ b/clients/cmd/docker-driver/Dockerfile @@ -1,16 +1,29 @@ ARG BUILD_IMAGE=grafana/loki-build-image:0.34.0 +ARG GOARCH=amd64 # 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/loki -f cmd/loki/Dockerfile . +# docker build -t grafana/loki-docker-driver -f clients/cmd/docker-driver/Dockerfile . -# TODO: add cross-platform support FROM $BUILD_IMAGE AS build COPY . /src/loki WORKDIR /src/loki -RUN make clean && make BUILD_IN_CONTAINER=false clients/cmd/docker-driver/docker-driver -FROM alpine:3.20.3 -RUN apk add --update --no-cache ca-certificates tzdata +ARG GOARCH +RUN make clean && make BUILD_IN_CONTAINER=false GOARCH=${GOARCH} clients/cmd/docker-driver/docker-driver + +FROM alpine:3.20.3 AS temp + +ARG GOARCH + +RUN apk add --update --no-cache --arch=${GOARCH} ca-certificates tzdata + +FROM --platform=linux/${GOARCH} alpine:3.20.3 + +COPY --from=temp /etc/ca-certificates.conf /etc/ca-certificates.conf +COPY --from=temp /usr/share/ca-certificates /usr/share/ca-certificates +COPY --from=temp /usr/share/zoneinfo /usr/share/zoneinfo + COPY --from=build /src/loki/clients/cmd/docker-driver/docker-driver /bin/docker-driver + WORKDIR /bin/ ENTRYPOINT [ "/bin/docker-driver" ] diff --git a/docs/sources/send-data/docker-driver/_index.md b/docs/sources/send-data/docker-driver/_index.md index 092857732c807..5fdb9c208eecd 100644 --- a/docs/sources/send-data/docker-driver/_index.md +++ b/docs/sources/send-data/docker-driver/_index.md @@ -31,6 +31,9 @@ Run the following command to install the plugin, updating the release version if ```bash docker plugin install grafana/loki-docker-driver:2.9.2 --alias loki --grant-all-permissions ``` +{{% admonition type="note" %}} +Add `-arm64` to the image tag for AMR64 hosts. +{{% /admonition %}} To check installed plugins, use the `docker plugin ls` command. Plugins that have started successfully are listed as enabled: