Skip to content

Commit d51c758

Browse files
authored
Merge pull request #143 from rostilos/1.5.1-rc
feat: Update Dockerfiles to download New Relic Java agent dynamically…
2 parents 4636825 + 421d05f commit d51c758

2 files changed

Lines changed: 28 additions & 16 deletions

File tree

java-ecosystem/services/pipeline-agent/Dockerfile.observable

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,37 +6,41 @@ COPY ./target/codecrow-pipeline-agent-1.0.jar ./codecrow-pipeline-agent-1.0.jar
66

77
FROM openjdk:17.0.2-jdk-slim-bullseye
88

9-
109
RUN apt-get update && \
11-
apt-get install -y curl && \
10+
apt-get install -y curl unzip && \
1211
apt-get clean && \
1312
rm -rf /var/lib/apt/lists/*
1413

1514
RUN groupadd -r appgroup && useradd -r -g appgroup appuser
16-
RUN mkdir -p /app/logs /usr/local/newrelic
17-
15+
RUN mkdir -p /app/logs && chown -R appuser:appgroup /app
1816

1917
WORKDIR /app
2018

2119
# Copy the built jar file
22-
#COPY ./codecrow-pipeline-agent/mcp-server ./codecrow-pipeline-agent/mcp-server
2320
COPY --from=builder /app/codecrow-pipeline-agent-1.0.jar app.jar
2421

25-
COPY newrelic.jar /usr/local/newrelic/newrelic.jar
26-
COPY newrelic.yml /usr/local/newrelic/newrelic.yml
27-
RUN chown -R appuser:appgroup /app /usr/local/newrelic && \
28-
chmod 644 /usr/local/newrelic/newrelic.jar
22+
# Download New Relic Java agent (config newrelic.yml is mounted at runtime)
23+
RUN mkdir -p /usr/local/newrelic && \
24+
curl -fsSL https://download.newrelic.com/newrelic/java-agent/newrelic-agent/current/newrelic-java.zip \
25+
-o /tmp/newrelic-java.zip && \
26+
unzip -jo /tmp/newrelic-java.zip 'newrelic/newrelic.jar' -d /usr/local/newrelic/ && \
27+
rm /tmp/newrelic-java.zip && \
28+
chmod 644 /usr/local/newrelic/newrelic.jar && \
29+
chown -R appuser:appgroup /app /usr/local/newrelic
2930

30-
#NEW Relic installation
3131
# Change ownership
32-
RUN chown -R appuser:appgroup /app
32+
RUN chown appuser:appgroup app.jar
3333

3434
# Switch to non-root user
3535
USER appuser
3636

3737
# Expose port
3838
EXPOSE 8082
3939

40+
# New Relic config via environment (override at runtime via docker-compose)
41+
# NEW_RELIC_APP_NAME and NEW_RELIC_LICENSE_KEY must be set at runtime
42+
ENV NEW_RELIC_LOG_FILE_NAME=STDOUT
43+
4044
# JVM options
4145
ENV JAVA_OPTS="-Xms512m -Xmx1g -javaagent:/usr/local/newrelic/newrelic.jar -XX:+UseG1GC -XX:G1HeapRegionSize=16m -XX:+UseStringDeduplication"
4246

java-ecosystem/services/web-server/Dockerfile.observable

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ COPY ./target/codecrow-web-server-1.0-exec.jar ./codecrow-web-server-1.0.jar
77
FROM openjdk:17.0.2-jdk-slim-bullseye
88

99
RUN apt-get update && \
10-
apt-get install -y curl && \
10+
apt-get install -y curl unzip && \
1111
apt-get clean && \
1212
rm -rf /var/lib/apt/lists/*
1313

@@ -19,10 +19,14 @@ WORKDIR /app
1919
# Copy the built jar file
2020
COPY --from=builder /app/codecrow-web-server-1.0.jar app.jar
2121

22-
COPY newrelic.jar /usr/local/newrelic/newrelic.jar
23-
COPY newrelic.yml /usr/local/newrelic/newrelic.yml
24-
RUN chown -R appuser:appgroup /app /usr/local/newrelic && \
25-
chmod 644 /usr/local/newrelic/newrelic.jar
22+
# Download New Relic Java agent (config newrelic.yml is mounted at runtime)
23+
RUN mkdir -p /usr/local/newrelic && \
24+
curl -fsSL https://download.newrelic.com/newrelic/java-agent/newrelic-agent/current/newrelic-java.zip \
25+
-o /tmp/newrelic-java.zip && \
26+
unzip -jo /tmp/newrelic-java.zip 'newrelic/newrelic.jar' -d /usr/local/newrelic/ && \
27+
rm /tmp/newrelic-java.zip && \
28+
chmod 644 /usr/local/newrelic/newrelic.jar && \
29+
chown -R appuser:appgroup /app /usr/local/newrelic
2630

2731
# Change ownership
2832
RUN chown appuser:appgroup app.jar
@@ -37,6 +41,10 @@ EXPOSE 8081
3741
HEALTHCHECK --interval=30s --timeout=10s --start-period=60s --retries=3 \
3842
CMD curl -f http://localhost:8081/actuator/health || exit 1
3943

44+
# New Relic config via environment (override at runtime via docker-compose)
45+
# NEW_RELIC_APP_NAME and NEW_RELIC_LICENSE_KEY must be set at runtime
46+
ENV NEW_RELIC_LOG_FILE_NAME=STDOUT
47+
4048
# JVM options
4149
ENV JAVA_OPTS="-Xms512m -Xmx1g -javaagent:/usr/local/newrelic/newrelic.jar -XX:+UseG1GC -XX:G1HeapRegionSize=16m -XX:+UseStringDeduplication"
4250

0 commit comments

Comments
 (0)