Skip to content

Commit

Permalink
improve dockerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
Jesus Samitier committed Nov 2, 2023
1 parent 1ac67d0 commit ed82387
Showing 1 changed file with 7 additions and 17 deletions.
24 changes: 7 additions & 17 deletions build/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,36 +1,26 @@
FROM maven:3.8.5-openjdk as javabuilder

RUN mkdir /opt/jmx_exporter
COPY . /opt/jmx_exporter
WORKDIR /opt/jmx_exporter/
WORKDIR /opt/jmx_exporter
COPY . .
RUN mvn package -DskipTests

FROM anapsix/alpine-java:9 as scratch

RUN apk update && apk upgrade && apk --update add curl && rm -rf /tmp/* /var/cache/apk/*

ENV VERSION 0.20.1
ENV JAR jmx_prometheus_httpserver-$VERSION.jar
COPY --from=javabuilder /opt/jmx_exporter/jmx_prometheus_httpserver/target/jmx_prometheus_httpserver-$VERSION-SNAPSHOT.jar /opt/jmx_exporter/$JAR
COPY build/start.sh /opt/jmx_exporter
COPY build/config.yml /opt/jmx_exporter
RUN chmod +x /opt/jmx_exporter/start.sh

CMD ["/opt/jmx_exporter/start.sh"]

FROM quay.io/sysdig/sysdig-mini-ubi:1.5.8 as ubi
RUN mkdir -p /opt/jmx_exporter

RUN microdnf --assumeyes --disableplugin=subscription-manager --nodocs update && \
microdnf --assumeyes --disableplugin=subscription-manager --nodocs install curl java-1.8.0-openjdk && \
microdnf --assumeyes --disableplugin=subscription-manager --nodocs clean all && \
rm -rf /usr/lib/python3.6 && \
rm -rf /var/cache/yum

ENV VERSION 0.20.1
ENV JAR jmx_prometheus_httpserver-$VERSION.jar

COPY --from=javabuilder /opt/jmx_exporter/jmx_prometheus_httpserver/target/jmx_prometheus_httpserver-$VERSION-SNAPSHOT.jar /opt/jmx_exporter/$JAR
COPY --chown=sysdig:sysdig build/start.sh /opt/jmx_exporter
COPY --chown=sysdig:sysdig build/config.yml /opt/jmx_exporter

RUN chmod +x /opt/jmx_exporter/start.sh

USER sysdig:sysdig

CMD ["/opt/jmx_exporter/start.sh"]

0 comments on commit ed82387

Please sign in to comment.