Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question: How to add a separate .jar as a Java Agent and modify Docker image ENTRYPOINT args #212

Closed
LoPan455 opened this issue Aug 18, 2022 · 2 comments
Labels

Comments

@LoPan455
Copy link

I've successfully built and run the Kubernetes "flavor" of the Spring Pet Clinic Microservices project. I'd like to add a 3rd party JAR file to the output image, but I am failing to see where I can the directives to download the desired Java Agent .jar file and modify the default ENTRYPOINT directive to add the -javaagent flag to the ENTRYPOINT.

After reviewing the parent pom.xml and researching the spring-boot-maven-plugin docs, it appears that all I would need to do would be to modify the Dockerfile that's the basis for each service's Docker image, but it doesn't appear that a Dockerfile is used when this command is invoked:

./mvnw spring-boot:build-image -Pk8s -DREPOSITORY_PREFIX=${REPOSITORY_PREFIX} && ./scripts/pushImages.sh

Based on how I understand the project is designed, the Dockerfile located at <project root path>/docker/Dockerfile is only used when this command is executed:

./mvnw clean install -P buildDocker

I think I'm losing the trail of breadcrumbs to understand how all the pieces fit together. Any guidance on where I can define my additional requirements of adding an additional .jar file to the output image and modify the ENTRYPOINT directive in that image would be greatly appreciated.

I have been able to discover a means to download and place the Java Agent .jar file into a specific module's target path with the following addition to the module's pom.xml. This case, I added to the spring-petclinic-customers-service module with the following xml snippet:

<plugin>
                <groupId>com.googlecode.maven-download-plugin</groupId>
                <artifactId>maven-download-plugin</artifactId>
                <version>1.0.0</version>
                <executions>
                    <execution>
                        <id>fetch-java-agent</id>
                        <phase>generate-resources</phase>
                        <goals>
                            <goal>wget</goal>
                        </goals>
                        <configuration>
                            <url>path-to-my-third-party-jar</url>
                            <unpack>false</unpack>
                            <outputDirectory>${project.build.directory}</outputDirectory>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

I feel like this might be part of the overall solution, but I am not sure how this would be copied into the image, nor how to modify the ENTRYPOINT command.

@arey arey added the question label Aug 19, 2022
@arey
Copy link
Member

arey commented Aug 19, 2022

Hi @LoPan455
It looks like your question is related to the https://github.com/spring-petclinic/spring-petclinic-cloud/ project and not this spring-petclinic-microservice project that does not provide k8s support. If you confirm, I propose you copy your question in a new issue
Regards

@LoPan455
Copy link
Author

@arey You are correct, my mistake. Thank you for the response.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants