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 ba48c6d
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 3 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>testcontainers</artifactId>
<version>1.18.0</version>
<version>1.19.3</version>
<scope>test</scope>
</dependency>
</dependencies>
Expand Down
26 changes: 24 additions & 2 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,41 @@ WORKDIR /app
# Copy the pom.xml and Maven files and install the dependencies
COPY .mvn .mvn/
COPY pom.xml mvnw mvnw.cmd ./

# Test containers bug doesn't seem to allow mount cache
# RUN --mount=type=cache,id=mavenCache,target=/root/.m2,sharing=locked \
RUN set -eu && \
./mvnw dependency:resolve;

# Copy the source code and build the JAR file
COPY src/ src/

# Test containers bug doesn't seem to allow mount cache
# RUN --mount=type=cache,id=mavenCache,target=/root/.m2,sharing=locked \
RUN 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

# 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 .

# RMI Port
EXPOSE 9090

# Control Port
EXPOSE 9091

# Supervisor Port
EXPOSE 9092

# 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="-Xmx128M -Xms128M"

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

0 comments on commit ba48c6d

Please sign in to comment.