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

Dockerize prometheus-exporter #6

Open
gitbuda opened this issue Oct 21, 2023 · 0 comments
Open

Dockerize prometheus-exporter #6

gitbuda opened this issue Oct 21, 2023 · 0 comments

Comments

@gitbuda
Copy link
Member

gitbuda commented Oct 21, 2023

Example/proposal

FROM alpine:latest AS stg1
RUN apk add --update --no-cache binutils
RUN apk add --update --no-cache python3 git py3-pip  && \
#    ln -sf python3 /usr/bin/python && \
    pip3 install --no-cache setuptools pipreqs pyinstaller && \
    git clone -b main --single-branch --depth 1 https://github.com/memgraph/prometheus-exporter.git /opt/prometheus_exporter
WORKDIR "/opt/prometheus_exporter"
#   get required libraries using pipreqs
RUN pipreqs --force /opt/prometheus_exporter && \
    python3 -m pip install -r /opt/prometheus_exporter/requirements.txt
#  build executable self contained on opt
RUN pyinstaller --onefile main.py && ln -s ./dist/main ./main

# finally, create the actual container to be run, with only the required files for the exporter and stored in opt
FROM alpine:latest AS stg3
EXPOSE 9115/tcp
ENV PYTHONUNBUFFERED=1
WORKDIR "/opt/prometheus_exporter"
COPY --from=stg1 /opt/prometheus_exporter/main /opt/prometheus_exporter/main
#  use echo to write out the config file
ENV MGDBSERVER=memgraph
RUN echo $'exporter:\n  port: 9115\nmemgraph:\n  endpoint_url: [http://127.0.0.1\n](http://127.0.0.1/n)  port: 9091\ngeneral:\n  pull_frequency_seconds: 5' > config.yaml  && \
    sed -i 's/[127.0.0.1/](http://127.0.0.1/)'"${MGDBSERVER}"'/g' /opt/prometheus_exporter/config.yaml
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

1 participant