Skip to content

Commit

Permalink
Added ability to change the final Docker image for misbehaving-jmx-se…
Browse files Browse the repository at this point in the history
…rver
  • Loading branch information
carlosroman committed Dec 14, 2023
1 parent 97afdbf commit aca6d7d
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 4 deletions.
18 changes: 14 additions & 4 deletions tools/misbehaving-jmx-server/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# syntax=docker/dockerfile:1
# Use by default the JDK image used to build the jar
ARG FINAL_JRE_IMAGE=base
# Use the official JDK image as the base image
FROM eclipse-temurin:17 AS base

Expand All @@ -9,22 +12,29 @@ WORKDIR /app
# Copy the pom.xml and Maven files and install the dependencies
COPY .mvn .mvn/
COPY pom.xml mvnw mvnw.cmd ./
RUN set -eu && \
RUN --mount=type=cache,target=/root/.m2 \
set -eu && \
./mvnw dependency:resolve;

# Copy the source code and build the JAR file
COPY src/ src/
RUN set -eu && \
RUN --mount=type=cache,target=/root/.m2 \
set -eu && \
./mvnw clean package assembly:single;

# Use the base image as the the final image
FROM base AS final
FROM ${FINAL_JRE_IMAGE} AS final
#FROM eclipse-temurin:${JDK_VERSION} AS final

# Set the working directory to /app
WORKDIR /app

COPY scripts/start.sh /usr/bin/

# Copy the JAR file from the Maven image to the final image
COPY --from=build /app/target/misbehavingjmxserver-1.0-SNAPSHOT-jar-with-dependencies.jar .

# Run the supervisor class from the jar
CMD ["java", "-cp", "misbehavingjmxserver-1.0-SNAPSHOT-jar-with-dependencies.jar", "org.datadog.supervisor.App"]
ENTRYPOINT [ "/usr/bin/start.sh" ]

CMD [ "org.datadog.supervisor.App" ]
13 changes: 13 additions & 0 deletions tools/misbehaving-jmx-server/scripts/start.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/usr/bin/env sh

set -f

echo "Running $@"

[ -n "$JAVA_OPTS" ] || JAVA_OPTS="-Xmx256M -Xms256M"

# shellcheck disable=SC2086
java \
${JAVA_OPTS} \
-cp misbehavingjmxserver-1.0-SNAPSHOT-jar-with-dependencies.jar \
"$@"

0 comments on commit aca6d7d

Please sign in to comment.