Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Which grok-exporter Dockerfile? #1

Closed
jesperronn opened this issue Feb 10, 2021 · 4 comments
Closed

Which grok-exporter Dockerfile? #1

jesperronn opened this issue Feb 10, 2021 · 4 comments

Comments

@jesperronn
Copy link
Contributor

Hi Emil, thanks for providing these scripts open-source.

I have a question about

https://github.com/magenta-aps/apache_log_exporter/blob/master/docker-compose.yml#L9

  grok_exporter:
    image: magentaaps/grok_exporter:latest-rc

I cannot find the dockerfile anywhere to supposedly build the image. Where do I find it?

@Skeen
Copy link
Member

Skeen commented Feb 10, 2021

I believe this should be the image: https://hub.docker.com/r/magentaaps/grok_exporter

@jesperronn
Copy link
Contributor Author

Thanks for the fast reply. My question is not about the image. My question is where to find the dockerfile used to build the image :)

@Skeen
Copy link
Member

Skeen commented Feb 10, 2021

Ah! - I'm sorry! - My bad. It's on our internal gitlab repository, but I can reproduce it here:

#############################
# Multi-Stage Build

FROM golang:stretch as builder
ENV GITHUB_REPOSITORY=github.com/magenta-aps/grok_exporter

# Install system deps
#   We need this in order to build oniguruma.
#   The debian deb packages for onigurma do not install static libs
RUN apt-get update && apt-get -y install build-essential make autoconf libtool

# Oniguruma: fetch, build, and install static libs
RUN cd /tmp && \
    git clone https://github.com/kkos/oniguruma.git && \
    cd /tmp/oniguruma && \
    autoreconf -vfi && \
    ./configure && \
    make && \
    make install

# grok_exporter: fetch source code
RUN mkdir -p /go/src/$GITHUB_REPOSITORY
RUN git clone https://$GITHUB_REPOSITORY.git /go/src/$GITHUB_REPOSITORY

# Fetch Golang Dependencies
WORKDIR /go/src/$GITHUB_REPOSITORY
RUN git submodule update --init --recursive
RUN go get

# Build Statically-Linked Binary
RUN GOOS=linux GOARCH=amd64 CGO_ENABLED=1 go build \
    -ldflags "-w -extldflags \"-static\" \
    -X ./exporter.Version=$VERSION \
    -X ./exporter.BuildDate=$(date +%Y-%m-%d) \
    -X ./exporter.Branch=$(git rev-parse --abbrev-ref HEAD) \
    -X ./exporter.Revision=$(git rev-parse --short HEAD) \
    "

RUN cp /go/src/$GITHUB_REPOSITORY/grok_exporter /srv/grok_exporter
RUN cp -r /go/src/$GITHUB_REPOSITORY/logstash-patterns-core /srv/logstash-patterns-core

#############################
# Final-Stage Build

FROM alpine:latest

WORKDIR /app

COPY --from=builder /srv/grok_exporter /app/grok_exporter
COPY --from=builder /srv/logstash-patterns-core /app/logstash-patterns-core

EXPOSE 9144
ENTRYPOINT [ "/app/grok_exporter" ]

Let me know if you need any more help, and I apologize for misunderstanding!

@Skeen
Copy link
Member

Skeen commented Feb 10, 2021

I think I just kinda hijacked the Dockerfile from here: https://github.com/fstab/grok_exporter/pull/62/files

And the only changes to the magenta-aps/grok_exporter repository is the inclusion of fstab/grok_exporter#100, maybe other PRs too.

I'm afraid I do not remember the details, but you should be able to derive it from the commits on that repository if you so desire.

  • Either way the it looks like the json_lines webhook input format has been merged, so there may not be any need for our fork.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants