Last active
July 9, 2023 06:46
-
-
Save joe-mccann-dev/a09a89294632912becc46b4ba68c7811 to your computer and use it in GitHub Desktop.
Attach Debugger to Remote JVM using Debugger for Java Extension in VS Code when using Docker containers.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# syntax=docker/dockerfile:1 | |
FROM eclipse-temurin:17-jdk-jammy as base | |
WORKDIR /app | |
COPY .mvn/ .mvn | |
COPY mvnw pom.xml ./ | |
RUN ./mvnw dependency:resolve | |
COPY src ./src | |
FROM base as development | |
# exposing 8000 in development enables attaching to remote jvm debugger | |
EXPOSE 8000 | |
CMD ["./mvnw", "spring-boot:run", "-Dspring-boot.run.profiles=mysql", "-Dspring-boot.run.jvmArguments='-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:8000'"] | |
FROM base as build | |
RUN ./mvnw package | |
FROM eclipse-temurin:17-jre-jammy as production | |
EXPOSE 8080 | |
COPY --from=build /app/target/spring-petclinic-*.jar /spring-petclinic.jar | |
CMD ["java", "-Djava.security.egd=file:/dev/./urandom", "-jar", "/spring-petclinic.jar"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"version": "0.2.0", | |
"configurations": [ | |
{ | |
"type": "java", | |
"name": "Attach to Remote JVM", | |
"projectName": "spring-petclinic", | |
"request": "attach", | |
"hostName": "localhost", | |
"port": "8000", | |
}, | |
] | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.