stleary-json-java
SUCCESS
18m 47s
History Source
SummaryIterations1Transcript18Dockerfile
01Iteration 1
WRITEWriteFile· step #1
0s
Dockerfile697 chars
text23 lines · 697 chars
# Multi-stage Dockerfile to build JSON-Java library (OSGi bundle) from source using Maven (IBM Java 8)

# Stage 1: Build with Maven (IBM Java 8)
FROM maven:3.9.15-ibmjava-8 AS builder
WORKDIR /build

# Copy pom and then sources to leverage caching
COPY pom.xml .
COPY src ./src

# Build the project (includes tests)
RUN mvn -DskipTests=false clean package

# Stage 2: Runtime image
FROM openjdk:8-jre-slim
WORKDIR /app

# Copy the built artifact from the builder stage
COPY --from=builder /build/target/json-20251224.jar /app/json-20251224.jar

# Default command: show artifact information and keep container alive
CMD ["sh","-c","echo \"Built artifact: /app/json-20251224.jar\"; sleep infinity"]
DOCKERDockerImageSearch· step #2
0s
search docker hubopenjdk:8-jre-slim1 results
show lines1
Image openjdk:8-jre-slim NOT found on Docker Hub.
WRITEWriteFile· step #3
0s
Dockerfile692 chars
text23 lines · 692 chars
# Multi-stage Dockerfile to build JSON-Java library (OSGi bundle) from source using Maven (IBM Java 8)

# Stage 1: Build with Maven (IBM Java 8)
FROM maven:3.9.15-ibmjava-8 AS builder
WORKDIR /build

# Copy pom and then sources to leverage caching
COPY pom.xml .
COPY src ./src

# Build the project (includes tests)
RUN mvn -DskipTests=false clean package

# Stage 2: Runtime image
FROM openjdk:8-jre
WORKDIR /app

# Copy the built artifact from the builder stage
COPY --from=builder /build/target/json-20251224.jar /app/json-20251224.jar

# Default command: show artifact information and keep container alive
CMD ["sh","-c","echo \"Built artifact: /app/json-20251224.jar\"; sleep infinity"]
DOCKERDockerImageSearch· step #4
0s
search docker hubopenjdk 8 jre alpine10 results
show lines10
openjdk (4115 stars): Pre-release / non-production builds of OpenJDK
alpine/git (252 stars): A  simple git container running in alpine linux, especially for tiny linux distr
alpine/socat (115 stars): Run socat command in alpine container
alpine/curl (12 stars): 
alpine/helm (70 stars): Auto-trigger docker build for kubernetes helm when new release is announced
alpine/k8s (65 stars): Kubernetes toolbox for EKS (kubectl, helm, iam-authenticator, eksctl, etc)
alpine/bombardier (28 stars): Auto-trigger docker build for bombardier when new release is announced
alpine/httpie (22 stars): Auto-trigger docker build for `httpie` when new release is announced
alpine/terragrunt (19 stars): Auto-trigger docker build for terragrunt when new terraform version released
alpine/openssl (8 stars): openssl
WRITEWriteFile· step #5
0s
Dockerfile712 chars
text23 lines · 712 chars
# Multi-stage Dockerfile to build JSON-Java library (OSGi bundle) from source using Maven (IBM Java 8)

# Stage 1: Build with Maven (IBM Java 8)
FROM maven:3.9.15-ibmjava-8 AS builder
WORKDIR /build

# Copy pom and then sources to leverage caching
COPY pom.xml .
COPY src ./src

# Build the project (includes tests)
RUN mvn -DskipTests=false clean package

# Stage 2: Runtime image
FROM adoptopenjdk/openjdk8:jre-hotspot
WORKDIR /app

# Copy the built artifact from the builder stage
COPY --from=builder /build/target/json-20251224.jar /app/json-20251224.jar

# Default command: show artifact information and keep container alive
CMD ["sh","-c","echo \"Built artifact: /app/json-20251224.jar\"; sleep infinity"]
WRITEWriteFile· step #6
0s
Dockerfile713 bytes written
text21 lines · 713 chars
# Multi-stage Dockerfile to build JSON-Java library (OSGi bundle) from source using Maven (IBM Java 8)
FROM maven:3.9.15-ibmjava-8 AS builder
WORKDIR /workspace

# Copy pom and source to leverage Maven cache
COPY pom.xml .
COPY src ./src

# Build the project (includes tests)
RUN mvn -DskipTests=false clean package

# Stage 2: Runtime image. Reuse the same Maven JDK base so java is available.
FROM maven:3.9.15-ibmjava-8
WORKDIR /app

# Copy the built artifact from the builder stage
COPY --from=builder /workspace/target/json-20251224.jar /app/json-20251224.jar

# Default command: keep container alive and provide artifact info
CMD ["bash","-lc","echo Built artifact: /app/json-20251224.jar; sleep infinity"]
WRITEWriteFile· step #7
0s
.dockerignore206 bytes written
dockerignore21 lines · 206 chars
# Ignore common VCS/IDE/editor and build artifacts
.git
.gitignore
*.class
target
build
node_modules
.idea
.astral
*.log
.DS_Store
*.iml
.gradle
out
*.tmp
coverage
.settings
.env
docker-compose*.yml
.mvn
"}
VERIFYVerifyBuild· step #8
2m 21s
VerifyBuildsmoke_failed
Concerns: Runtime image reuses a Maven base for runtime; could optimize to a slimmer JRE/JDK-only image to reduce size, COPY --from=builder path assumes target json-20251224.jar exists; ensure artifact name exactly matches built jar
Smoke [FAIL]: sh -lc 'cat > /tmp/Test.java << "EOF"\nimport org.json.JSONObject;\npublic class Test {\n  public static void main(String[] args) {\n    JSONObject obj = new JSONObject();\n    obj.put("a", 1);\n    System.out.print(obj.toString());\n  }\n}\nEOF\njavac -cp /app/json-20251224.jar /tmp/Test.java\nOUTPUT=$(java -cp .:/app/json-20251224.jar Test)\necho "$OUTPUT" | grep -q \"a\":1 && echo PASS
  Output: sh: 1: Syntax error: Unterminated quoted string

Smoke [PASS]:
WRITEWriteFile· step #9
0s
Dockerfile744 bytes written
text23 lines · 744 chars
# Multi-stage Dockerfile to build JSON-Java library (OSGi bundle) from source using Maven (IBM Java 8)

# Stage 1: Build with Maven (IBM Java 8)
FROM maven:3.9.15-ibmjava-8 AS builder
WORKDIR /build

# Copy pom and source to leverage Maven cache
COPY pom.xml .
COPY src ./src

# Build the project (includes tests)
RUN mvn -DskipTests=false clean package

# Stage 2: Runtime image. Reuse the same Maven JDK base so Java is available.
FROM maven:3.9.15-ibmjava-8
WORKDIR /tmp

# Copy the built artifact from the builder stage
COPY --from=builder /build/target/json-20251224.jar /app/json-20251224.jar

# Default command: keep container alive and provide artifact info
CMD ["sh","-c","echo Built artifact: /app/json-20251224.jar; sleep infinity"]
VERIFYVerifyBuild· step #10
7m 32s
VerifyBuildsmoke_failed
Smoke [FAIL]: sh -c 'cat > /tmp/TestJson.java << "EOF"\nimport org.json.JSONObject;\npublic class TestJson {\n  public static void main(String[] args) {\n     JSONObject o = new JSONObject();\n     o.put("a", 1);\n     if (o.getInt("a") != 1) { System.err.println("unexpected"); System.exit(1); }\n     System.out.println("OK:"+o.getInt("a"));\n  }\n}\nEOF\njavac -cp /app/json-20251224.jar /tmp/TestJson.java\njava -cp /tmp:/app/json-20251224.jar TestJson | grep -q '^OK:1$' && echo PASS
  Output: sh: 1: Syntax error: Unterminated quoted string
DOCKERDockerImageSearch· step #11
0s
search docker hubopenjdk:8-jre1 results
show lines1
Image openjdk:8-jre NOT found on Docker Hub.
DOCKERDockerImageSearch· step #12
0s
search docker hubopenjdk:8-jre-alpine1 results
show lines1
Image openjdk:8-jre-alpine NOT found on Docker Hub.
WRITEWriteFile· step #13
0s
Dockerfile743 bytes written
text23 lines · 743 chars
# Multi-stage Dockerfile to build JSON-Java library (OSGi bundle) from source using Maven (IBM Java 8)

# Stage 1: Build with Maven (IBM Java 8)
FROM maven:3.9.15-ibmjava-8 AS builder
WORKDIR /build

# Copy pom and source to leverage Maven cache
COPY pom.xml .
COPY src ./src

# Build the project (includes tests)
RUN mvn -DskipTests=false clean package

# Stage 2: Runtime image. Use a lightweight JRE with Java 8 compatibility.
FROM eclipse-temurin:8-jre
WORKDIR /app

# Copy the built artifact from the builder stage
COPY --from=builder /build/target/json-20251224.jar /app/json-20251224.jar

# Default command: provide artifact info and keep container alive
CMD ["bash","-lc","echo Built artifact: /app/json-20251224.jar; sleep infinity"]
VERIFYVerifyBuild· step #14
1m 28s
VerifyBuildsmoke_failed
Concerns: The final stage CMD uses bash -lc; ensure /bin/bash exists in eclipse-temurin:8-jre, otherwise the container may fail to start., The artifact name / build output is hard-coded as json-20251224.jar; verify this matches the actual Maven build artifact to avoid COPY failures., Using a Java 8 JRE image may or may not include certain shell utilities (e.g., jar) depending on the distro; consider using explicit tools or a lighter test strategy.
Smoke [FAIL]: jar tf /app/json-20251224.jar | grep -q '^org/json/JSONObject.class$' && echo OK
  Output: sh: 1: jar: not found

Smoke [FAIL]: jar tf /app/json-20251224.jar | grep -q 'META-INF/MANIFEST.MF' && echo OK
  Output: sh: 1: jar: not found
WRITEWriteFile· step #15
0s
Dockerfile754 bytes written
text23 lines · 754 chars
# Multi-stage Dockerfile to build JSON-Java library (OSGi bundle) from source using Maven (IBM Java 8)

# Stage 1: Build with Maven (IBM Java 8)
FROM maven:3.9.15-ibmjava-8 AS builder
WORKDIR /build

# Copy pom and source to leverage Maven cache
COPY pom.xml .
COPY src ./src

# Build the project (includes tests)
RUN mvn -DskipTests=false clean package

# Stage 2: Runtime image. Use a runtime JDK with Java 8 support to run the artifact.
FROM maven:3.9.15-ibmjava-8
WORKDIR /app

# Copy the built artifact from the builder stage
COPY --from=builder /build/target/json-20251224.jar /app/json-20251224.jar

# Default command: provide artifact info and keep container alive
CMD ["bash","-lc","echo Built artifact: /app/json-20251224.jar; sleep infinity"]
VERIFYVerifyBuild· step #16
55s
VerifyBuildsmoke_failed
Concerns: Artifact path risk: The COPY --from=builder /build/target/json-20251224.jar assumes a jar named json-20251224.jar is produced. If the Maven coordinates produce a different artifact name (artifactId/version), the COPY will fail., Runtime image is heavyweight: Using the Maven IBM Java 8 image for runtime means a much larger image than necessary. Consider using a slim JRE/JDK image for runtime and only copy the built jar., Lack of health/entrypoint behavior: The container simply echoes the path and sleeps. There is no healthcheck, no automated validation of runtime behavior, and no non-root user/secure defaults.
Smoke [FAIL]: sh -c 'cat > /tmp/TestJson.java <<"EOF"
import org.json.JSONObject;
public class TestJson {
  public static void main(String[] args) {
    String s = "{\"a\":1,\"b\":2}";
    JSONObject obj = new JSONObject(s);
    System.out.println(obj.getInt("a"));
  }
}
EOF
javac -cp /app/json-20251224.jar /tmp/TestJson.java
java -cp /app/json-20251224.jar:/tmp TestJson | grep -q 1 && echo PASS
  Output: sh: 12: Syntax error: Unterminated quoted string
WRITEWriteFile· step #17
0s
Dockerfile815 bytes written
text26 lines · 815 chars
# Multi-stage Dockerfile to build JSON-Java library (OSGi bundle) from source using Maven (IBM Java 8)

# Stage 1: Build with Maven (IBM Java 8)
FROM maven:3.9.15-ibmjava-8 AS builder
WORKDIR /build

# Copy pom and source to leverage Maven cache
COPY pom.xml .
COPY src ./src

# Build the project (includes tests)
RUN mvn -DskipTests=false clean package

# Stage 2: Runtime image. Use a runtime JDK with Java 8 support to run the artifact.
FROM maven:3.9.15-ibmjava-8
WORKDIR /app

# Copy the built artifact from the builder stage
COPY --from=builder /build/target/json-20251224.jar /app/json-20251224.jar

# Optional: create a simple logs dir
RUN mkdir -p /app/logs

# Default command: provide artifact info and keep container alive
CMD ["bash","-lc","echo Built artifact: /app/json-20251224.jar; sleep infinity"]
VERIFYVerifyBuild· step #18
1m 22s
VerifyBuildaccepted
Concerns: The COPY --from=builder /build/target/json-20251224.jar may fail if the built artifact name/version differs from the exact path used (json-20251224.jar). Consider using a more robust artifact selection (e.g., mvn -D... -DskipTests -Dartifact=... to locate the jar) or pattern-based copy., Runtime image uses a full Maven IBM Java 8 image instead of a minimal JRE/runtime; this increases image size. Consider using a dedicated JRE runtime or a multi-stage final image with only production dependencies.
Smoke [PASS]: set -e; cat > /tmp/SmokeTest.java <<'JAVA'
import org.json.JSONObject;
public class SmokeTest { public static void main(String[] args) { JSONObject o = new JSONObject("{\"a\":1}"); int v = o.getInt("a"); if (v != 1) { System.err.println("FAIL"); System.exit(1); } System.out.println("OK"); } }
JAVA
javac -cp /app/json-20251224.jar /tmp/SmokeTest.java
java -cp /tmp:/app/json-20251224.jar SmokeTest | grep -q OK