From a41a67e047a257cd122300108fa8b91819995e0b Mon Sep 17 00:00:00 2001 From: Alexander Shilokhvostov Date: Tue, 22 Oct 2024 16:16:56 +0700 Subject: [PATCH] Migrate to filebeat 8.5.1 --- Dockerfile | 32 ++++++++++++++++++++++++-------- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/Dockerfile b/Dockerfile index ae1c605..4e42714 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,21 +1,37 @@ -ARG filebeatVersion=6.5.4 -ARG goVersion=1.10.6 -FROM golang:$goVersion +ARG filebeatVersion=8.5.1 +ARG goVersion=1.18.7 +FROM docker.elastic.co/beats/filebeat:$filebeatVersion +USER root ARG filebeatVersion +ARG goVersion + +RUN apt-get update && \ + apt-get install -y curl wget tar gcc git + +RUN wget https://go.dev/dl/go$goVersion.linux-amd64.tar.gz -O - | tar -C /usr/local -xzf - + RUN curl -L --output /tmp/filebeat.tar.gz https://github.com/elastic/beats/archive/v$filebeatVersion.tar.gz RUN mkdir -p /go/src/github.com/elastic/beats && tar -xvzf /tmp/filebeat.tar.gz --strip-components=1 -C /go/src/github.com/elastic/beats -RUN go get -v golang.org/x/vgo COPY . /go/src/github.com/ozonru/filebeat-throttle-plugin COPY register/plugin/plugin.go /go/src/github.com/elastic/beats/libbeat/processors/throttle/plugin.go -RUN (cd /go/src/github.com/ozonru/filebeat-throttle-plugin && vgo mod vendor -v) -RUN rm -rf /go/src/github.com/ozonru/filebeat-throttle-plugin/vendor/github.com/elastic -RUN go build -v -o /output/filebeat_throttle_linux.so -buildmode=plugin github.com/elastic/beats/libbeat/processors/throttle +ENV GOPATH=/go +ENV PATH=$PATH:/usr/local/go/bin + +RUN cd /go/src/github.com/ozonru/filebeat-throttle-plugin && \ + go mod vendor -v +RUN cd /go/src/github.com/elastic/beats/libbeat/processors/throttle && \ + go get github.com/elastic/beats/libbeat/processors && \ + go get github.com/ozonru/filebeat-throttle-plugin + +ENV CGO_ENABLED=1 +RUN cd /go/src/github.com/ozonru/filebeat-throttle-plugin/throttle && \ + GOOS=linux go build -v -o /go/src/github.com/ozonru/filebeat-throttle-plugin/output/filebeat_throttle_linux.so -buildmode=plugin FROM docker.elastic.co/beats/filebeat:$filebeatVersion -COPY --from=0 /output/filebeat_throttle_linux.so /filebeat_throttle_linux.so +COPY --from=0 /go/src/github.com/ozonru/filebeat-throttle-plugin/output/filebeat_throttle_linux.so /filebeat_throttle_linux.so CMD ["-e", "--plugin", "/filebeat_throttle_linux.so"]