From 57b465b5567189c47fec54138b051e9e591bda34 Mon Sep 17 00:00:00 2001 From: Riley Easland Date: Tue, 20 Oct 2020 14:01:31 -0500 Subject: [PATCH 1/5] initial commit --- Dockerfile | 25 ++++++++++++++----------- README.md | 8 ++++---- docker_push | 2 +- start.sh | 15 --------------- 4 files changed, 19 insertions(+), 31 deletions(-) delete mode 100755 start.sh diff --git a/Dockerfile b/Dockerfile index 2f0c8d5..05552d0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,16 +1,19 @@ -FROM anapsix/alpine-java:8 -MAINTAINER sscaling +FROM openjdk:8-jre -RUN apk update && apk upgrade && apk --update add curl && rm -rf /tmp/* /var/cache/apk/* +ARG buildversion=0.14.0 +ARG buildjar=jmx_prometheus_httpserver-$buildversion-jar-with-dependencies.jar -ENV VERSION 0.12.0 -ENV JAR jmx_prometheus_httpserver-$VERSION-jar-with-dependencies.jar +ENV version $buildversion +ENV jar $buildjar +ENV SERVICE_PORT 5556 +ENV CONFIG_YML ~/jmx_exporter/config.yml -RUN curl --insecure -L https://github.com/Yelp/dumb-init/releases/download/v1.2.2/dumb-init_1.2.2_amd64 -o usr/local/bin/dumb-init && chmod +x /usr/local/bin/dumb-init +RUN useradd -ms /bin/bash prom_exporter +USER prom_exporter +WORKDIR /home/prom_exporter -RUN mkdir -p /opt/jmx_exporter -RUN curl -L https://repo1.maven.org/maven2/io/prometheus/jmx/jmx_prometheus_httpserver/$VERSION/$JAR -o /opt/jmx_exporter/$JAR -COPY start.sh /opt/jmx_exporter/ -COPY config.yml /opt/jmx_exporter/ +RUN mkdir -p ~/jmx_exporter +RUN curl -L https://repo1.maven.org/maven2/io/prometheus/jmx/jmx_prometheus_httpserver/$version/$jar -o ~/jmx_exporter/$jar +COPY config.yml ~/jmx_exporter/ -CMD ["usr/local/bin/dumb-init", "/opt/jmx_exporter/start.sh"] +CMD ["sh", "-c", "java $JVM_OPTS -jar ~/jmx_exporter/$jar $SERVICE_PORT $CONFIG_YML" ] \ No newline at end of file diff --git a/README.md b/README.md index 093451b..c092c95 100644 --- a/README.md +++ b/README.md @@ -5,20 +5,20 @@ Docker JMX exporter for Prometheus Essentially another dockerised JMX Exporter image, this uses alpine-java and dumb-init to provide a relatively small image (approx 130Mb) and includes a released version of jmx_exporter from the [maven central repository](https://repo1.maven.org/maven2/io/prometheus/jmx/jmx_prometheus_httpserver/) -Available on [Docker hub](https://hub.docker.com/r/sscaling/jmx-prometheus-exporter/) +Available on [Docker hub](https://hub.docker.com/r/reasland/jmx-prometheus-exporter/) Building docker image --------------------- ``` -docker build -t sscaling/jmx-prometheus-exporter . +docker build -t reasland/jmx-prometheus-exporter . ``` Running ------- ``` -docker run --rm -p "5556:5556" sscaling/jmx-prometheus-exporter +docker run --rm -p "5556:5556" reasland/jmx-prometheus-exporter ``` Then you can visit the metrics endpoint: [http://127.0.0.1:5556/metrics](http://127.0.0.1:5556/metrics) (assuming docker is running on localhost) @@ -29,7 +29,7 @@ Configuration By default, the jmx-exporter is configured to monitor it's own metrics (as per the main repo example). However, to provide your own configuration, mount the YAML file as a volume ``` -docker run --rm -p "5556:5556" -v "$PWD/config.yml:/opt/jmx_exporter/config.yml" sscaling/jmx-prometheus-exporter +docker run --rm -p "5556:5556" -v "$PWD/config.yml:/opt/jmx_exporter/config.yml" reasland/jmx-prometheus-exporter ``` The configuration options are documented: [https://github.com/prometheus/jmx_exporter](https://github.com/prometheus/jmx_exporter) diff --git a/docker_push b/docker_push index 4fd3736..e2d18a8 100755 --- a/docker_push +++ b/docker_push @@ -1,6 +1,6 @@ #!/bin/bash -e -BASE_IMAGE="sscaling/jmx-prometheus-exporter" +BASE_IMAGE="reasland/jmx-prometheus-exporter" IMAGE_VERSION="$1" if [ -z "$IMAGE_VERSION" ]; then diff --git a/start.sh b/start.sh deleted file mode 100755 index 537bd54..0000000 --- a/start.sh +++ /dev/null @@ -1,15 +0,0 @@ -#!/bin/sh - -if [ -z "$SERVICE_PORT" ]; then - SERVICE_PORT=5556 -fi - -if [ -z "$JVM_OPTS" ]; then - JVM_OPTS="-Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.port=5555" -fi - -if [ -z "$CONFIG_YML" ]; then - CONFIG_YML=/opt/jmx_exporter/config.yml -fi - -java $JVM_OPTS -jar /opt/jmx_exporter/jmx_prometheus_httpserver-$VERSION-jar-with-dependencies.jar $SERVICE_PORT $CONFIG_YML From fe299091293540fd6b90572836efb8170c7637a1 Mon Sep 17 00:00:00 2001 From: Riley Easland Date: Tue, 20 Oct 2020 14:11:54 -0500 Subject: [PATCH 2/5] update readme for build args --- README.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/README.md b/README.md index c092c95..a1cf78d 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,13 @@ Building docker image docker build -t reasland/jmx-prometheus-exporter . ``` +### Build Arguments + +Additionally, the following build arguments can be defined + +- version - default 0.14.0 - what version of the jmx_exporter http server to use (if you are going to docker push, please tag prom_jmx:$VERSION) +- jar - default jmx_prometheus_httpserver-$VERSION-jar-with-dependencies.jar - what jar file from the maven repo https://repo1.maven.org/maven2/io/prometheus/jmx/jmx_prometheus_httpserver/ to use + Running ------- From 21b5d3eebf7c976704ea9d5438000e8734064702 Mon Sep 17 00:00:00 2001 From: Riley Easland Date: Tue, 20 Oct 2020 14:12:24 -0500 Subject: [PATCH 3/5] readme updates --- README.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/README.md b/README.md index a1cf78d..0b25d85 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,3 @@ -[![Build status](https://travis-ci.com/sscaling/docker-jmx-prometheus-exporter.svg?branch=master)](https://travis-ci.com/sscaling/docker-jmx-prometheus-exporter) [![Docker Pulls](https://img.shields.io/docker/pulls/sscaling/jmx-prometheus-exporter.svg)](https://hub.docker.com/r/sscaling/jmx-prometheus-exporter) - Docker JMX exporter for Prometheus ================================== From 172a092e185316345366b95290e43bcd1cdfb509 Mon Sep 17 00:00:00 2001 From: Riley Easland Date: Tue, 20 Oct 2020 15:15:43 -0500 Subject: [PATCH 4/5] dockerfile updates --- Dockerfile | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/Dockerfile b/Dockerfile index 05552d0..56516e7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,19 +1,21 @@ FROM openjdk:8-jre -ARG buildversion=0.14.0 +ARG buildversion=0.13.0 ARG buildjar=jmx_prometheus_httpserver-$buildversion-jar-with-dependencies.jar ENV version $buildversion ENV jar $buildjar ENV SERVICE_PORT 5556 -ENV CONFIG_YML ~/jmx_exporter/config.yml +ENV CONFIG_YML /opt/jmx_exporter/config.yml +ENV JVM_OPTS -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.port=5555 +RUN mkdir -p /opt/jmx_exporter RUN useradd -ms /bin/bash prom_exporter +RUN chown prom_exporter:prom_exporter /opt/jmx_exporter + USER prom_exporter -WORKDIR /home/prom_exporter -RUN mkdir -p ~/jmx_exporter -RUN curl -L https://repo1.maven.org/maven2/io/prometheus/jmx/jmx_prometheus_httpserver/$version/$jar -o ~/jmx_exporter/$jar -COPY config.yml ~/jmx_exporter/ +RUN curl -L https://repo1.maven.org/maven2/io/prometheus/jmx/jmx_prometheus_httpserver/$version/$jar -o /opt/jmx_exporter/$jar +COPY config.yml /opt/jmx_exporter/ -CMD ["sh", "-c", "java $JVM_OPTS -jar ~/jmx_exporter/$jar $SERVICE_PORT $CONFIG_YML" ] \ No newline at end of file +CMD ["sh", "-c", "java $JVM_OPTS -jar /opt/jmx_exporter/$jar $SERVICE_PORT $CONFIG_YML" ] \ No newline at end of file From 13e634060391780d5b8b60997aae982ec52e1d19 Mon Sep 17 00:00:00 2001 From: Riley Easland Date: Tue, 20 Oct 2020 17:47:33 -0500 Subject: [PATCH 5/5] woops --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 56516e7..6d945cf 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,6 @@ FROM openjdk:8-jre -ARG buildversion=0.13.0 +ARG buildversion=0.14.0 ARG buildjar=jmx_prometheus_httpserver-$buildversion-jar-with-dependencies.jar ENV version $buildversion