# Stage 1: Build the ZXing multi-module project (core and android-core to avoid Android toolchains) FROM maven:3.9-ibm-semeru-21-noble AS builder # Working directory for the build WORKDIR /workspace # Copy the repository sources into the build container COPY . . # Build only the core and android-core modules to produce runnable artifacts, skip tests to accelerate RUN mvn -nsu -B install -pl core,android-core -am -DskipTests # Stage 2: Minimal runtime image containing the built artifacts FROM eclipse-temurin:21-jre-jammy AS runtime # Prepare a directory to hold ZXing artifacts WORKDIR /opt/zxing # Copy built artifacts from the builder stage. We copy the entire target directories to keep filenames intact. COPY --from=builder /workspace/core/target /opt/zxing/core-target COPY --from=builder /workspace/android-core/target /opt/zxing/android-core-target # Default command: drop into a shell so users can inspect the artifacts or run simple java commands CMD ["bash"]
# Ignore git and many local artifacts to keep the image lean .git .gradle build out target *.log *.tmp *.class .DS_Store # Node modules and packages (if accidentally present) node_modules npm-debug.log # IDE/Editors .vscode .idea *.iml # Maven local repository (optional; if we want to copy over dependencies, this helps drastic reduce size) .m2
Summary (concise, preserving actionable details) - VerifyBuild status: build_failed - Concerns: - COPY of /workspace/core/target and /workspace/android-core/target into /opt/zxing/core-target and /opt/zxing/android-core-target flattens dirs; may confuse filenames. Consider preserving original target dirs or copying only needed artifacts. - Container CMD is a shell; not a runnable entrypoint. Consider adding a default Java command to run a sample artifact or provide guidance in docs. - Build error (maven/BUILD step): - Exact issue: Could not find the selected project in the reactor: android-core - Additional: Could not find the selected project in the reactor: android-core -> [Help 1] - Guidance: Re-run Maven with -e for full stack trace; re-run with -X for debug logging - Error line: ERROR: failed to build: failed to solve: process "/bin/sh -c mvn -nsu -B install -pl core,android-core -am -DskipTests" did not complete successfully: exit code: 1 - Failing command/step: - RUN mvn -nsu -B install -pl core,android-core -am -DskipTests - Missing packages/files mentioned: - android-core module not found in the Maven reactor (Could not find the selected project in the reactor: android-core). May mean the reactor/project tree lacks android-core as a module listed in -pl, or the module isn’t present/accessible in the build context. - Version mismatch info: - No explicit version mismatch reported. - Build uses base images: maven:3.9-ibm-semeru-21-noble and eclipse-temurin:21-jre-jammy - Issue appears to be module availability in the reactor, not Maven/Java version mismatch. - Context note: - Occurs during final builder step (builder 4/4) while attempting to install core and android-core without tests.
# Stage 1: Build the ZXing multi-module project from source FROM maven:3.9-ibm-semeru-21-noble AS builder # Working directory for the build WORKDIR /workspace # Copy the repository sources into the build container COPY . . # Build the project from source (skip tests for a faster build; you can enable tests if needed) RUN mvn -nsu -B install -DskipTests # Stage 2: Minimal runtime image containing the built artifacts FROM eclipse-temurin:21-jre-jammy AS runtime # Prepare a directory to hold ZXing artifacts WORKDIR /opt/zxing # Copy all built artifacts from the builder stage COPY --from=builder /workspace /opt/zxing/workspace # Default command: drop into a shell so users can inspect the artifacts or run simple java commands CMD ["bash"]
Concerns: Final runtime image uses a bash shell as CMD; there is no explicit runnable artifact configured; users may expect to run a jar or service., COPY from builder copies the entire workspace; could be optimized to copy only built artifacts to reduce image size and improve clarity., Build step uses -DskipTests; if tests are important, consider enabling them or adding a dedicated test stage. Smoke [PASS]: ls -la /opt/zxing/workspace Smoke [PASS]: java -version Smoke [PASS]: find /opt/zxing/workspace -name "*.jar" | head -1