Skip to content

Commit 6926352

Browse files
Harden java dedup sample docker flow
Signed-off-by: Asish Kumar <officialasishkumar@gmail.com>
1 parent ac01c9b commit 6926352

3 files changed

Lines changed: 12 additions & 31 deletions

File tree

java-dedup/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@ COPY --chown=10001:10001 target/classes /app/target/classes
1313
ENV KEPLOY_JAVA_CLASS_DIRS=/app/target/classes
1414
EXPOSE 8080
1515
USER 10001:10001
16-
ENTRYPOINT ["java", "-javaagent:/app/jacocoagent.jar", "-jar", "/app/app.jar"]
16+
ENTRYPOINT ["java", "-javaagent:/app/jacocoagent.jar=destfile=/tmp/jacoco.exec", "-jar", "/app/app.jar"]

java-dedup/README.md

Lines changed: 11 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -6,52 +6,37 @@ CI does not record this sample. The `keploy/` directory is checked in so the pip
66

77
The Java SDK reads JaCoCo coverage in-process via `org.jacoco.agent.rt.RT.getAgent().getExecutionData(...)`, so attaching the JaCoCo Java agent is enough — no TCP server, no port choice, no `--pass-through-ports`.
88

9-
## Build
9+
## Setup
1010

1111
```bash
12+
(cd ../../java-sdk && mvn -B -DskipTests -Dgpg.skip=true install -pl keploy-sdk -am)
1213
mvn -B -DskipTests package
1314
```
1415

15-
This produces `target/java-dedup-0.0.1-SNAPSHOT.jar` and copies `target/jacocoagent.jar` next to it.
16+
This installs the sibling SDK snapshot locally, builds the sample, produces `target/java-dedup-0.0.1-SNAPSHOT.jar`, and copies `target/jacocoagent.jar` next to it.
1617

1718
## Run dedup natively
1819

1920
```bash
2021
keploy test \
2122
-c "java -javaagent:target/jacocoagent.jar -jar target/java-dedup-0.0.1-SNAPSHOT.jar" \
22-
--dedup --language java --delay 20
23+
--dedup --language java --delay 20 \
24+
--disableMockUpload --disableReportUpload
25+
26+
keploy dedup --path .
2327
```
2428

2529
## Run dedup with Docker
2630

27-
Build the image (the Dockerfile already attaches the JaCoCo agent):
28-
2931
```bash
3032
docker compose build
31-
```
32-
33-
Replay with dedup:
34-
35-
```bash
3633
keploy test \
3734
-c "docker compose up" \
3835
--container-name "dedup-java" \
39-
--dedup --language java --delay 20
40-
```
36+
--dedup --language java --delay 20 \
37+
--disableMockUpload --disableReportUpload
4138

42-
The Compose file bind-mounts host `/tmp` into the container so Keploy and the Java SDK share `/tmp/coverage_control.sock` and `/tmp/coverage_data.sock`.
43-
44-
### Restricted Docker
45-
46-
For a read-only root filesystem with dropped capabilities and `no-new-privileges`, overlay the restricted compose file:
47-
48-
```bash
49-
docker compose -f docker-compose.yml -f docker-compose.restricted.yml build
50-
51-
keploy test \
52-
-c "docker compose -f docker-compose.yml -f docker-compose.restricted.yml up" \
53-
--container-name "dedup-java" \
54-
--dedup --language java --delay 20
39+
keploy dedup --path .
5540
```
5641

57-
Host `/tmp` is still bind-mounted so the SDK and Keploy share the dedup Unix sockets.
42+
During `keploy test`, Enterprise rewrites the Compose file and injects its own shared `/tmp` volume for the dedup control/data sockets. The base sample Compose file does not need a host `/tmp` bind mount.

java-dedup/docker-compose.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,3 @@ services:
1111
- "${JAVA_DEDUP_HOST_PORT:-8080}:8080"
1212
environment:
1313
KEPLOY_JAVA_CLASS_DIRS: /app/target/classes
14-
volumes:
15-
- type: bind
16-
source: /tmp
17-
target: /tmp

0 commit comments

Comments
 (0)