FROM eclipse-temurin:11-jdk AS build WORKDIR /workspace # Install necessary system dependencies RUN apt-get update \ && apt-get install -y --no-install-recommends ca-certificates curl \ && rm -rf /var/lib/apt/lists/* # Prepare Maven wrapper directory (will be populated automatically if missing) RUN mkdir -p .mvn/wrapper # Copy build configuration and sources COPY mvnw . COPY .mvn /workspace/.mvn || true COPY pom.xml pom.xml COPY src src RUN chmod +x mvnw # Build the project from sources (skip tests to keep image build light) RUN ./mvnw -q -DskipTests package -Dlicense.skip=true ################################################################# # Runtime image FROM eclipse-temurin:11-jre-slim AS runtime WORKDIR /app # Copy the built artifacts from the build stage COPY --from=build /workspace/target /app/target # Default command: drop into a shell so the container is usable CMD ["/bin/bash"]
FROM eclipse-temurin:11-jdk AS build WORKDIR /workspace # Install necessary system dependencies RUN apt-get update \ && apt-get install -y --no-install-recommends ca-certificates curl git \ && rm -rf /var/lib/apt/lists/* # Copy build configuration and sources COPY mvnw . COPY .mvn .mvn || true COPY pom.xml pom.xml COPY src src RUN chmod +x mvnw # Build the project from sources (skip tests to keep image build light) RUN ./mvnw -q -DskipTests package -Dlicense.skip=true ################################################################# # Runtime image FROM eclipse-temurin:11-jre AS runtime WORKDIR /app # Copy the built artifacts from the build stage COPY --from=build /workspace/target /app/target # Default command: drop into a shell so the container is usable CMD ["/bin/bash"]
target/ .git/ node_modules/ dist/ *.log *.class .DS_Store
Concerns: COPY .mvn .mvn || true is invalid Dockerfile syntax; COPY cannot use shell conditional like '|| true'. This will cause a build failure., The runtime CMD is just /bin/bash; the image does not automatically run the built JAR or expose a service, which may be expected for a built application image.
FROM eclipse-temurin:11-jdk AS build WORKDIR /workspace # Install necessary system dependencies RUN apt-get update \ && apt-get install -y --no-install-recommends ca-certificates curl \ && rm -rf /var/lib/apt/lists/* # Copy build configuration and sources COPY mvnw . COPY pom.xml pom.xml COPY src src RUN chmod +x mvnw # Build the project from sources (skip tests to keep image build light) RUN ./mvnw -q -DskipTests package -Dlicense.skip=true ################################################################# # Runtime image FROM eclipse-temurin:11-jre AS runtime WORKDIR /app # Copy the built artifacts from the build stage COPY --from=build /workspace/target /app/target # Entrypoint to run the built jar if present COPY docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh RUN chmod +x /usr/local/bin/docker-entrypoint.sh ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"]
Error: file not found: docker-entrypoint.sh
#!/bin/sh set -e if [ -f /app/target/*.jar ]; then JAR=$(basename /app/target/*.jar) exec java -jar /app/target/$JAR "$@" else echo "No jar built in /app/target" >&2 exec "$@" fi
Failing step - [build 8/8] RUN ./mvnw -q -DskipTests package -Dlicense.skip=true - Docker exit code: 1 Exact error messages (preserved): - ./mvnw: 227: cannot open /workspace/.mvn/wrapper/maven-wrapper.properties: No such file - /workspace/.mvn/wrapper/maven-wrapper.jar: No such file or directory - ./mvnw: 283: cannot open /workspace/.mvn/wrapper/maven-wrapper.properties: No such file - Error: Could not find or load main class org.apache.maven.wrapper.MavenWrapperMain - Caused by: java.lang.ClassNotFoundException: org.apache.maven.wrapper.MavenWrapperMain Missing files/packages mentioned - /workspace/.mvn/wrapper/maven-wrapper.properties - /workspace/.mvn/wrapper/maven-wrapper.jar Version mismatch information - None present in the log. Base images used: - build FROM eclipse-temurin:11-jdk - runtime FROM eclipse-temurin:11-jre Notes - The wrapper artifacts are missing, causing Maven Wrapper to fail to start.
FROM maven:3.8.7-openjdk-11 AS build WORKDIR /build # Copy pom and source COPY pom.xml pom.xml COPY src src # Build the project from sources RUN mvn -q -DskipTests package -Dlicense.skip=true ################################################################# # Runtime image FROM eclipse-temurin:11-jre-slim AS runtime WORKDIR /app # Copy the built artifacts from the build stage COPY --from=build /build/target /app/target # Entrypoint script to run the built jar if present COPY docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh RUN chmod +x /usr/local/bin/docker-entrypoint.sh ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"]
FROM eclipse-temurin:11-jdk AS build WORKDIR /workspace # Copy pom and source COPY pom.xml pom.xml COPY src src # Build the project from sources RUN ./mvnw -q -DskipTests package -Dlicense.skip=true || mvn -q -DskipTests package -Dlicense.skip=true ################################################################# # Runtime image FROM eclipse-temurin:11-jre AS runtime WORKDIR /app # Copy the built artifacts from the build stage COPY --from=build /workspace/target /app/target # Entrypoint script to run the built jar if present COPY docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh RUN chmod +x /usr/local/bin/docker-entrypoint.sh ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"]
Concerns: The build stage runs ./mvnw but does not copy mvnw and the .mvn directory from the build context; if the Maven wrapper is not present in the context, the command will fail. The fallback '|| mvn' will only succeed if Maven is installed in the base image, which eclipse-temurin:11-jdk typically does not provide., There is no COPY for mvnw (or the Maven wrapper directory) or .mvn, so the wrapper cannot be used in the build unless those files are present elsewhere in the context., The docker-entrypoint.sh file is copied, but its existence is not guaranteed by the given Dockerfile alone; if it is missing from the build context, the runtime image will fail to build., The build command relies on either the wrapper or Maven being available; this is fragile and may fail in clean environments. Consider explicitly installing Maven or including the Maven wrapper and .mvn directory in the build context., No CMD is specified; although the entrypoint is set, it's generally helpful to have a clear default CMD or ensure the entrypoint script robustly locates and runs the jar.
FROM eclipse-temurin:11-jdk AS build WORKDIR /workspace # Install Maven if not present RUN apt-get update && apt-get install -y --no-install-recommends maven \ && rm -rf /var/lib/apt/lists/* # Copy pom and source COPY pom.xml pom.xml COPY src src # Build the project from sources RUN mvn -q -DskipTests package -Dlicense.skip=true ################################################################# # Runtime image FROM eclipse-temurin:11-jre AS runtime WORKDIR /app # Copy the built artifacts from the build stage COPY --from=build /workspace/target /app/target # Entrypoint script to run the built jar if present COPY docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh RUN chmod +x /usr/local/bin/docker-entrypoint.sh ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"]
Summary:
- Failing step: Build 6/6
- Command: RUN mvn -q -DskipTests package -Dlicense.skip=true
- Dockerfile:14
- Exit code: 1
- Exact error messages (from the failure):
- Failed to execute goal org.apache.maven.plugins:maven-enforcer-plugin:3.6.2:enforce on project mybatis:
- Rule 1: org.apache.maven.enforcer.rules.version.RequireJavaVersion failed with message:
Detected JDK /opt/java/openjdk is version 11.0.30 which is not in the allowed range [17,18),[21,22),[24,25),[25,26),[26,27).
- Rule 2: org.apache.maven.enforcer.rules.version.RequireMavenVersion failed with message:
Detected Maven Version: 3.8.7 is not in the allowed range [3.9.11,).
- -> [Help 1]
- Version/mismatch details:
- JDK detected: 11.0.30 (not in allowed ranges [17,18), [21,22), [24,25), [25,26), [26,27))
- Maven detected: 3.8.7 (not in allowed range [3.9.11,))
- Dockerfile context note (missing/related item mentioned):
- No JRE found. Skipping Java certificates setup.
- Missing packages or files mentioned:
- None explicitly missing; the failure is due to version constraints. The apt install log shows Java-related packages were installed, with the JRE path /opt/java/openjdk being version 11.0.30.
- Actionable fix suggestions:
- Use a base image with a Java version in the allowed ranges (e.g., Java 17/18 or 21/22 or 24/25/26/27).
- Upgrade Maven to at least 3.9.11 (or adjust the Enforcer rules if appropriate for your project).
- Final note: This is a build failure; the command did not complete successfully. exit code: 1FROM maven:3.9.11-openjdk-17 as build WORKDIR /workspace # Copy pom and source COPY pom.xml pom.xml COPY src src # Build the project from sources RUN mvn -q -DskipTests package -Dlicense.skip=true ################################################################# # Runtime image FROM eclipse-temurin:17-jre AS runtime WORKDIR /app # Copy the built artifacts from the build stage COPY --from=build /workspace/target /app/target # Entrypoint script to run the built jar if present COPY docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh RUN chmod +x /usr/local/bin/docker-entrypoint.sh ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"]
FROM eclipse-temurin:17-jdk AS build WORKDIR /workspace # Copy pom and source COPY pom.xml pom.xml COPY src src # Build the project from sources RUN mvn -q -DskipTests package -Dlicense.skip=true ################################################################# # Runtime image FROM eclipse-temurin:17-jre AS runtime WORKDIR /app # Copy the built artifacts from the build stage COPY --from=build /workspace/target /app/target # Entrypoint script to run the built jar if present COPY docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh RUN chmod +x /usr/local/bin/docker-entrypoint.sh ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"]
Exact error message and exit code - /bin/sh: 1: mvn: not found - Exit code: 127 Failing command/step - RUN mvn -q -DskipTests package -Dlicense.skip=true (Dockerfile: line 10) Missing packages or files mentioned - mvn (Maven) not found; Maven is not installed in the build image. Any version mismatch info - No explicit version mismatch info in the log. - Build uses eclipse-temurin:17-jdk for build and eclipse-temurin:17-jre for runtime.
FROM maven:3.9.11-openjdk-17 AS build WORKDIR /workspace # Copy pom and source COPY pom.xml pom.xml COPY src src # Build the project from sources RUN mvn -q -DskipTests package -Dlicense.skip=true ################################################################# # Runtime image FROM eclipse-temurin:17-jre AS runtime WORKDIR /app # Copy the built artifacts from the build stage COPY --from=build /workspace/target /app/target # Entrypoint script to run the built jar if present COPY docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh RUN chmod +x /usr/local/bin/docker-entrypoint.sh ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"]
FROM eclipse-temurin:11-jdk AS build # Install Maven to build the project from source RUN apt-get update \ && apt-get install -y --no-install-recommends maven \ && rm -rf /var/lib/apt/lists/* WORKDIR /workspace # Copy build configuration and sources COPY pom.xml pom.xml COPY src src # Build the project from sources RUN mvn -q -DskipTests package -Dlicense.skip=true ################################################################# # Runtime image FROM eclipse-temurin:11-jre AS runtime WORKDIR /app # Copy the built artifacts from the build stage COPY --from=build /workspace/target /app/target # Entrypoint script to run the built jar if present COPY docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh RUN chmod +x /usr/local/bin/docker-entrypoint.sh ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"]
- Failing step (build 6/6): RUN mvn -q -DskipTests package -Dlicense.skip=true - Exact error message and exit code: - ERROR: process "/bin/sh -c mvn -q -DskipTests package -Dlicense.skip=true" did not complete successfully: exit code: 1 - [ERROR] Failed to execute goal org.apache.maven.plugins:maven-enforcer-plugin:3.6.2:enforce on project mybatis: - [ERROR] Rule 1: org.apache.maven.enforcer.rules.version.RequireJavaVersion failed with message: - [ERROR] Detected JDK /opt/java/openjdk is version 11.0.30 which is not in the allowed range [17,18),[21,22),[24,25),[25,26),[26,27). - [ERROR] Rule 2: org.apache.maven.enforcer.rules.version.RequireMavenVersion failed with message: - [ERROR] Detected Maven Version: 3.8.7 is not in the allowed range [3.9.11,). - Missing packages or files mentioned: None explicitly listed; error is due to Java/Maven version constraints. - Version mismatch information: - Detected JDK version 11.0.30 is not in the allowed ranges [17,18), [21,22), [24,25), [25,26), [26,27). - Detected Maven Version: 3.8.7 is not in the allowed range [3.9.11,).
FROM openjdk:17-jdk-slim AS build
# Install dependencies to download and extract Maven
RUN apt-get update \
&& apt-get install -y --no-install-recommends curl ca-certificates tar gzip \
&& rm -rf /var/lib/apt/lists/*
ENV MAVEN_VERSION=3.9.11
ENV MAVEN_HOME=/usr/share/maven
RUN mkdir -p "$MAVEN_HOME" \
&& curl -fsSL https://archive.apache.org/dist/maven/maven-3/${MAVEN_VERSION}/binary/apache-maven-${MAVEN_VERSION}-bin.tar.gz -o /tmp/maven.tar.gz \
&& tar -xz -f /tmp/maven.tar.gz -C /usr/share/maven --strip-components=1 \
&& rm /tmp/maven.tar.gz
ENV PATH="$MAVEN_HOME/bin:$PATH"
WORKDIR /workspace
# Copy build configuration and sources
COPY pom.xml pom.xml
COPY src src
# Build the project from sources
RUN mvn -q -DskipTests package -Dlicense.skip=true
#################################################################
# Runtime image
FROM openjdk:17-jre-slim AS runtime
WORKDIR /app
# Copy the built artifacts from the build stage
COPY --from=build /workspace/target /app/target
# Entrypoint script to run the built jar if present
COPY docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh
RUN chmod +x /usr/local/bin/docker-entrypoint.sh
ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"]
FROM eclipse-temurin:17-jdk AS build
# Install build dependencies and Maven
RUN apt-get update \
&& apt-get install -y --no-install-recommends curl ca-certificates tar bash \
&& rm -rf /var/lib/apt/lists/*
ENV MAVEN_VERSION=3.9.11
ENV MAVEN_HOME=/usr/share/maven
# Download and install Maven
RUN mkdir -p "$MAVEN_HOME" \
&& curl -fsSL https://archive.apache.org/dist/maven/maven-3/${MAVEN_VERSION}/binaries/apache-maven-${MAVEN_VERSION}-bin.tar.gz -o /tmp/maven.tar.gz \
&& tar -xz -f /tmp/maven.tar.gz -C /usr/share/maven --strip-components=1 \
&& rm /tmp/maven.tar.gz
ENV PATH="$MAVEN_HOME/bin:$PATH"
WORKDIR /workspace
# Copy build configuration and sources
COPY pom.xml pom.xml
COPY src src
# Build the project from sources
RUN mvn -q -DskipTests package -Dlicense.skip=true
#################################################################
# Runtime image
FROM eclipse-temurin:17-jre AS runtime
WORKDIR /app
# Copy the built artifacts from the build stage
COPY --from=build /workspace/target /app/target
# Entrypoint script to run the built jar if present
COPY docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh
RUN chmod +x /usr/local/bin/docker-entrypoint.sh
ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"]
No matches found.
#!/bin/sh set -e if [ -f /app/target/*.jar ]; then JAR=$(basename /app/target/*.jar) exec java -jar /app/target/$JAR "$@" else echo "No jar built in /app/target" >&2 exec "$@" fi
- Failing step: [build 7/7] RUN mvn -q -DskipTests package -Dlicense.skip=true - Exact error message and exit code: - [ERROR] Failed to execute goal com.rudikershaw.gitbuildhook:git-build-hook-maven-plugin:3.6.0:install (default) on project mybatis: Could not find or initialise a local git repository. A repository is required. -> [Help 1] - The overall command did not complete successfully: exit code: 1 - Missing packages/files mentioned: - The error indicates a missing/local Git repository. A repository is required; likely the build context does not contain a .git directory (i.e., no local Git repo initialized for the git-buildhook-maven-plugin). - Version mismatch info: - GitBuildHook Maven Plugin version: com.rudikershaw.gitbuildhook:git-build-hook-maven-plugin:3.6.0 - Base images involved: eclipse-temurin:17-jdk and eclipse-temurin:17-jre (no explicit version mismatch reported).
# syntax=docker/dockerfile:1 # Build stage: use a Maven image with JDK 17 FROM maven:3.9.6-eclipse-temurin-17 AS build WORKDIR /workspace # Copy project metadata and sources. Caching benefits from pom.xml being copied first. COPY pom.xml ./ COPY src ./src # Build the project, skipping tests to speed up image creation and skipping license checks if configured. RUN mvn -B -Dlicense.skip=true -DskipTests package # Runtime stage: use a slim JRE to run the built artifact FROM eclipse-temurin:17-jre AS runtime WORKDIR /app # Create a non-root user to run the application RUN groupadd -r app && useradd -r -g app -d /app app # Copy the built artifacts from the build stage COPY --from=build /workspace/target /app/target # Copy an entrypoint wrapper that will execute the built jar COPY docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh RUN chmod +x /usr/local/bin/docker-entrypoint.sh USER app WORKDIR /app ENTRYPOINT ["docker-entrypoint.sh"]
#!/bin/sh set -e # Find the jar built by Maven in /app/target JAR=$(ls /app/target/*.jar 2>/dev/null | head -n 1) if [ -z "$JAR" ]; then echo "No jar file found in /app/target" >&2 exit 1 fi exec java -jar "$JAR" "$@"
# Ignore VCS and build-related files .git .gitignore target .DS_Store *.class *.log *.lock # Ignore OS files Thumbs.db ehthumbs.db # Ignore IDE files *.idea *.iml # Maven and build caches .mvndirs .mvn
Summary (under 1500 chars): - Exact error message and exit code: [ERROR] Failed to execute goal org.apache.maven.plugins:maven-enforcer-plugin:3.6.2:enforce (enforce-java) on project mybatis: [ERROR] Rule 2: org.apache.maven.enforcer.rules.version.RequireMavenVersion failed with message: [ERROR] Detected Maven Version: 3.9.6 is not in the allowed range [3.9.11,). [ERROR] -> [Help 1] Dockerfile:12 ERROR: failed to build: failed to solve: process "/bin/sh -c mvn -B -Dlicense.skip=true -DskipTests package" did not complete successfully: exit code: 1 - Failing command/step: RUN mvn -B -Dlicense.skip=true -DskipTests package (Dockerfile:12) - Missing packages or files mentioned: None reported as missing. The log shows extensive dependency downloads succeeding; the failure is due to Maven version enforcement, not missing artifacts. - Version mismatch info: - Detected Maven Version: 3.9.6 - Allowed range: [3.9.11,) - Enforcer plugin: maven-enforcer-plugin:3.6.2 (enforce-java) failed due to RequireMavenVersion - The Docker image uses Maven 3.9.6 (image: maven:3.9.6-eclipse-temurin-17). Fix: upgrade to Maven 3.9.11+ or use a base image with a newer Maven, or adjust the enforcer rules.
# syntax=docker/dockerfile:1 # Build stage: use a Maven image with JDK 17 FROM maven:3.9.11-eclipse-temurin-17 AS build WORKDIR /workspace # Copy project metadata and sources. Caching benefits from pom.xml being copied first. COPY pom.xml ./ COPY src ./src # Build the project, skipping tests to speed up image creation and skipping license checks if configured. RUN mvn -B -Dlicense.skip=true -DskipTests package # Runtime stage: use a slim JRE to run the built artifact FROM eclipse-temurin:17-jre AS runtime WORKDIR /app # Create a non-root user to run the application RUN groupadd -r app && useradd -r -g app -d /app app # Copy the built artifacts from the build stage COPY --from=build /workspace/target /app/target # Copy an entrypoint wrapper that will execute the built jar COPY docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh RUN chmod +x /usr/local/bin/docker-entrypoint.sh USER app WORKDIR /app ENTRYPOINT ["docker-entrypoint.sh"]
- Exact error message and exit code - [ERROR] Failed to execute goal com.rudikershaw.gitbuildhook:git-build-hook-maven-plugin:3.6.0:install (default) on project mybatis: Could not find or initialise a local git repository. A repository is required. -> [Help 1] - Exit code: 1 - The failing command/step - RUN mvn -B -Dlicense.skip=true -DskipTests package (Dockerfile:12), build step 5/5 - Missing packages or files mentioned - Missing: a local git repository is required by the git-build-hook-maven-plugin; no repository could be found/initialised in the build context. - No specific OS package or file path missing beyond the required git repository context. - Version mismatch information - Plugin version: com.rudikershaw.gitbuildhook:git-build-hook-maven-plugin:3.6.0 - Maven image: docker.io/library/maven:3.9.11-eclipse-temurin-17 - Base/runtime images: eclipse-temurin:17-jre and Maven 3.9.11 with Temurin-17 JVM - Project version: mybatis 3.6.0-SNAPSHOT - Java runtime: OpenJDK 17 (Temurin 17)
No results found.
# syntax=docker/dockerfile:1 # Build stage: use a Maven image with JDK 17 FROM maven:3.9.11-eclipse-temurin-17 AS build WORKDIR /workspace # Copy the entire repository (including .git) to ensure hooks/plugins have access COPY . . # Build the project, skipping tests to speed up image creation and skipping license checks if configured. RUN mvn -B -Dlicense.skip=true -DskipTests package # Runtime stage: use a slim JRE to run the built artifact FROM eclipse-temurin:17-jre AS runtime WORKDIR /app # Create a non-root user to run the application RUN groupadd -r app && useradd -r -g app -d /app app # Copy the built artifacts from the build stage COPY --from=build /workspace/target /app/target # Copy an entrypoint wrapper that will execute the built jar COPY docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh RUN chmod +x /usr/local/bin/docker-entrypoint.sh USER app WORKDIR /app ENTRYPOINT ["docker-entrypoint.sh"]
- Exact error message and exit code - Exit code: 1 - Error: [ERROR] Failed to execute goal com.rudikershaw.gitbuildhook:git-build-hook-maven-plugin:3.6.0:install (default) on project mybatis: Could not find or initialise a local git repository. A repository is required. -> [Help 1] - Failing command/step - build step: [build 4/4] RUN mvn -B -Dlicense.skip=true -DskipTests package - Result: BUILD FAILURE (exit code 1) - Missing packages or files mentioned - Missing: a local Git repository for the build (no .git in the build context). The git-build-hook-maven-plugin requires an initialized Git repository. - Version mismatch info - Build image uses Maven 3.9.11 with Eclipse Temurin JRE 17 (maven:3.9.11-eclipse-temurin-17) and base runtime eclipse-temurin:17-jre. - Git plugin involved: com.rudikershaw.gitbuildhook:git-build-hook-maven-plugin:3.6.0 - No explicit version mismatch indicated; failure is due to missing Git repository rather than incompatible versions.
# syntax=docker/dockerfile:1 # Build stage: use a Maven image with JDK 17 FROM maven:3.9.11-eclipse-temurin-17 AS build WORKDIR /workspace # Initialize a minimal git repository in the build context to satisfy git-build-hook-maven-plugin # and install git if not present RUN apt-get update \ && apt-get install -y --no-install-recommends git ca-certificates \ && rm -rf /var/lib/apt/lists/* \ && git init # Copy the entire repository (including .git) to ensure hooks/plugins have access COPY . . # Build the project, skipping tests to speed up image creation and skipping license checks if configured. RUN mvn -B -Dlicense.skip=true -DskipTests package # Runtime stage: use a slim JRE to run the built artifact FROM eclipse-temurin:17-jre AS runtime WORKDIR /app # Create a non-root user to run the application RUN groupadd -r app && useradd -r -g app -d /app app # Copy the built artifacts from the build stage COPY --from=build /workspace/target /app/target # Copy an entrypoint wrapper that will execute the built jar COPY docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh RUN chmod +x /usr/local/bin/docker-entrypoint.sh USER app WORKDIR /app ENTRYPOINT ["docker-entrypoint.sh"]
- Failing step (Docker build): RUN mvn -B -Dlicense.skip=true -DskipTests package (build stage 5/5)
- Exact error message and exit code:
- Within the build:
[ERROR] Failed to execute goal io.github.git-commit-id:git-commit-id-maven-plugin:9.0.2:revision (git-commit-id) on project mybatis: Could not get HEAD Ref, are you sure you have some commits in the dotGitDirectory (currently set to /workspace/.git)? -> [Help 1]
- Docker/overall exit: The process did not complete successfully: exit code: 1
- Failing command/step details:
- Command: mvn -B -Dlicense.skip=true -DskipTests package
- Context: In Dockerfile, this is the build step that triggers the failure.
- Missing packages or files mentioned:
- Root cause in error: HEAD reference missing in the dotGitDirectory. Specifically, the Git repository at /workspace/.git does not have a HEAD ref (no commits in the dotGitDirectory). This is what prevented the git-commit-id-maven-plugin from retrieving a revision.
- Version mismatch/info:
- Git plugin version: io.github.git-commit-id:git-commit-id-maven-plugin:9.0.2
- Maven image base: maven:3.9.11-eclipse-temurin-17 (Java 17)
- No other explicit package mismatches shown; the issue is the missing HEAD in /workspace/.git, not a dependency version mismatch.# syntax=docker/dockerfile:1 # Build stage: use a Maven image with JDK 17 FROM maven:3.9.11-eclipse-temurin-17 AS build WORKDIR /workspace # Install git and essential tools and ensure non-interactive apt RUN apt-get update \ && apt-get install -y --no-install-recommends git ca-certificates \ && rm -rf /var/lib/apt/lists/* # Copy the repository into the image. This will include .git so git-commit-id plugin can read HEAD. COPY . . # Build the project. We try to keep it non-interactive and skip tests to speed up builds. RUN mvn -B -Dlicense.skip=true -DskipTests package -Dgit.commit.id.ignore=true -Dgit.build.time=now # Runtime stage: use a slim JRE to run the built artifact FROM eclipse-temurin:17-jre AS runtime WORKDIR /app # Create a non-root user to run the application RUN groupadd -r app && useradd -r -g app -d /app app # Copy the built artifacts from the build stage COPY --from=build /workspace/target /app/target # Copy an entrypoint wrapper that will execute the built jar COPY docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh RUN chmod +x /usr/local/bin/docker-entrypoint.sh USER app WORKDIR /app ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"]
- Exact error message and exit code - ERROR] Failed to execute goal com.rudikershaw.gitbuildhook:git-build-hook-maven-plugin:3.6.0:install (default) on project mybatis: Could not find or initialise a local git repository. A repository is required. -> [Help 1] - Exit code: 1 - Failing command/step - [build 5/5] RUN mvn -B -Dlicense.skip=true -DskipTests package -Dgit.commit.id.ignore=true -Dgit.build.time=now - Missing packages or files mentioned - Local git repository not found; the git-build-hook-maven-plugin requires a repository. No explicit missing OS packages/files are named in the error (the apt-get step shows git/ca-certificates installed, but the failure is due to the missing Git repo). - Version mismatch/info - Plugin: com.rudikershaw.gitbuildhook:git-build-hook-maven-plugin:3.6.0 - Base image: maven:3.9.11-eclipse-temurin-17 - The failure is tied to the git-build-hook-maven-plugin not finding/initializing a git repo, not a compilation/maven version mismatch.
# syntax=docker/dockerfile:1 # Build stage: use a Maven image with JDK 17 FROM maven:3.9.11-eclipse-temurin-17 AS build WORKDIR /workspace # Cache-friendly build: copy pom.xml first, then sources COPY pom.xml ./ COPY src ./src # Build the project. Skip tests and skip the git-commit-id plugin to avoid requiring a Git repo. RUN mvn -B -Dlicense.skip=true -DskipTests -Dgit-commit-id-plugin.skip=true package # Runtime stage: use a slim JRE to run the built artifact FROM eclipse-temurin:17-jre AS runtime WORKDIR /app # Create a non-root user to run the application RUN groupadd -r app && useradd -r -g app -d /app app # Copy the built artifacts from the build stage COPY --from=build /workspace/target /app/target # Copy an entrypoint wrapper that will execute the built jar COPY docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh RUN chmod +x /usr/local/bin/docker-entrypoint.sh USER app WORKDIR /app ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"]
- Exact error message and exit code - Exit code: 1 - Failing text: “Could not find or initialise a local git repository. A repository is required.” (from: com.rudikershaw.gitbuildhook:git-build-hook-maven-plugin:3.6.0:install on project mybatis) - Full failure context: “BUILD FAILURE” followed by the git-build-hook plugin error for project mybatis. - Failing command/step - Dockerfile step: RUN mvn -B -Dlicense.skip=true -DskipTests -Dgit-commit-id-plugin.skip=true package (build 5/5) - Missing packages or files mentioned - Local git repository not found: Could not find or initialise a local git repository. A repository is required. This indicates the build context lacks a Git repository needed by the git-build-hook-maven-plugin. - Version mismatch/info - git-build-hook-maven-plugin version: 3.6.0 - git-commit-id-maven-plugin version observed earlier: 9.0.2 (though the build uses -Dgit-commit-id-plugin.skip=true to skip it) - No explicit version mismatch reported; the failure is due to the missing Git repository required by the git-build-hook-maven-plugin.
No results found.
No results found.
# syntax=docker/dockerfile:1 # Build stage: use a Maven image with JDK 17 FROM maven:3.9.11-eclipse-temurin-17 AS build WORKDIR /workspace # Install git and essential tools and ensure non-interactive apt RUN apt-get update \ && apt-get install -y --no-install-recommends git ca-certificates \ && rm -rf /var/lib/apt/lists/* # Copy the repository into the image. This will include .git so git-commit-id plugin can read HEAD. COPY . . # Initialize a local git repository (if none exists) and commit the context to satisfy git-based plugins RUN git init \ && git add -A \ && git -c user.email="build@example.com" -c user.name="BuildAgent" commit -m "Prepare git repo for build context" # Build the project. Skip tests and skip the git-commit-id plugin to avoid requiring a separate environment. RUN mvn -B -Dlicense.skip=true -DskipTests -Dgit-commit-id-plugin.skip=true package # Runtime stage: use a slim JRE to run the built artifact FROM eclipse-temurin:17-jre AS runtime WORKDIR /app # Create a non-root user to run the application RUN groupadd -r app && useradd -r -g app -d /app app # Copy the built artifacts from the build stage COPY --from=build /workspace/target /app/target # Copy an entrypoint wrapper that will execute the built jar COPY docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh RUN chmod +x /usr/local/bin/docker-entrypoint.sh USER app WORKDIR /app ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"]
Concerns: COPY . . copies the entire repository and .git; consider adding a .dockerignore to reduce image size and speed up builds., The build uses -DskipTests; tests won't run during build, which may hide failures., The runtime image assumes docker-entrypoint.sh exists and can locate the built jar; if the jar name or location changes, the entrypoint may fail. Smoke [FAIL]: sh -lc 'test -d /app/target && ls -1 /app/target | head -n1 Output: sh: 1: Syntax error: Unterminated quoted string Smoke [FAIL]: sh -lc 'test -x /usr/local/bin/docker-entrypoint.sh Output: sh: 1: Syntax error: Unterminated quoted string Smoke [FAIL]: sh -lc 'java -version >/dev/null 2>&1 Output: sh: 1: Syntax error: Unterminated quoted string
#!/bin/sh set -e # Find the jar built by Maven in /app/target JAR=$(ls /app/target/*.jar 2>/dev/null | head -n 1) if [ -z "$JAR" ]; then echo "No jar file found in /app/target" >&2 exit 1 fi exec java -jar "$JAR" "$@"
Concerns: The RUN git init && git add -A && git -c user.email=... -c user.name=... commit ... will likely fail in many contexts: if the copied context already contains a .git directory, 'git init' reinitializes an existing repo and 'git commit' may fail with 'nothing to commit', breaking the build. This step is fragile and unnecessary for building from source., COPY . . copies the entire repo, including the .git directory, into the image. This leaks VCS metadata, can bloat the image, and introduces potential security or compliance concerns. Typically you would copy only the needed sources (without .git) or use a dedicated build context., Assuming docker-entrypoint.sh exists in the repo is fine, but if it’s missing or not executable, the runtime image could fail to start. This depends on the source layout and should be validated.
# syntax=docker/dockerfile:1 # Build stage: use a Maven image with JDK 17 FROM maven:3.9.11-eclipse-temurin-17 AS build WORKDIR /workspace # Copy pom.xml first for cache efficiency COPY pom.xml ./ # Copy the source tree COPY src ./src # Build the project. Try to skip tests and avoid git plugins; provide multiple skip flags just in case RUN mvn -B -Dlicense.skip=true -DskipTests -Dgit-commit-id-plugin.skip=true -Dgitbuildhook.skip=true package # Runtime stage: use a slim JRE to run the built artifact FROM eclipse-temurin:17-jre AS runtime WORKDIR /app # Create a non-root user to run the application RUN groupadd -r app && useradd -r -g app -d /app app # Copy the built artifacts from the build stage COPY --from=build /workspace/target /app/target # Copy an entrypoint wrapper that will execute the built jar COPY docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh RUN chmod +x /usr/local/bin/docker-entrypoint.sh USER app WORKDIR /app ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"]
- Exact error message and exit code - Could not find or initialise a local git repository. A repository is required. -> [Help 1] - Exit code: 1 - Failing command/step - RUN mvn -B -Dlicense.skip=true -DskipTests -Dgit-commit-id-plugin.skip=true -Dgitbuildhook.skip=true package - Missing packages or files mentioned - Missing local git repository (required by git-build-hook-maven-plugin). No Git repository found or initialised in the build context. - Version mismatch info - Plugin: com.rudikershaw.gitbuildhook:git-build-hook-maven-plugin:3.6.0 (install phase) - Java/Maven base images used: Maven 3.9.11 with Eclipse Temurin 17; runtime: eclipse-temurin:17-jre - No explicit version mismatch reported; failure due to missing Git repository rather than a version clash.
# syntax=docker/dockerfile:1 # Build stage: use a Maven image with JDK 17 FROM maven:3.9.11-eclipse-temurin-17 AS build WORKDIR /workspace # Copy only pom.xml and sources needed for build to leverage caching COPY pom.xml ./ COPY src ./src # Initialize a local git repository in the build context to satisfy git-based plugins RUN apt-get update \ && apt-get install -y --no-install-recommends git ca-certificates \ && rm -rf /var/lib/apt/lists/* \ && git init \ && git add -A \ && git -c user.email="build@example.com" -c user.name="BuildAgent" commit -m "Initial commit" # Build the project. Skip tests and avoid git-related plugin issues RUN mvn -B -Dlicense.skip=true -DskipTests -Dgit-commit-id-plugin.skip=true package # Runtime stage: use a slim JRE to run the built artifact FROM eclipse-temurin:17-jre AS runtime WORKDIR /app # Create a non-root user to run the application RUN groupadd -r app && useradd -r -g app -d /app app # Copy the built artifacts from the build stage COPY --from=build /workspace/target /app/target # Copy an entrypoint wrapper that will execute the built jar COPY docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh RUN chmod +x /usr/local/bin/docker-entrypoint.sh USER app WORKDIR /app ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"]
Concerns: COPY --from=build /workspace/target /app/target copies the entire target directory; this can bloat the image. Consider copying only the necessary artifact (e.g., a specific jar) and/or a minimal set of files., No HEALTHCHECK instruction is defined; adding a HEALTHCHECK would help detect unhealthy containers and improve reliability. Smoke [FAIL]: sh -lc '[ -d /app/target ] && [ "$(ls -A /app/target)" != "" ] Output: sh: 1: Syntax error: Unterminated quoted string Smoke [FAIL]: sh -lc 'command -v java >/dev/null 2>&1 && echo java-present Output: sh: 1: Syntax error: Unterminated quoted string Smoke [FAIL]: sh -lc 'pgrep -f java >/dev/null 2>&1 && echo java-running || exit 1 Output: sh: 1: Syntax error: Unterminated quoted string
# Build container for the MyBatis repository (library) FROM maven:3.9.2-openjdk-11 AS builder WORKDIR /workspace # Copy pom and wrapper first for dependency caching COPY pom.xml pom.xml COPY mvnw mvnw COPY .mvn .mvn # Pre-fetch dependencies (offline) to maximize caching RUN ./mvnw -B -Dlicense.skip=true -DskipTests dependency:go-offline || mvn -B -Dlicense.skip=true -DskipTests dependency:go-offline # Copy source and build the project COPY src src RUN ./mvnw -B -Dlicense.skip=true -DskipTests clean package FROM eclipse-temurin:11-jre-hotspot AS runtime WORKDIR /app # Copy the built artifacts from the builder stage COPY --from=builder /workspace/target /app/target # Copy the entrypoint script and make it executable COPY docker-entrypoint.sh /app/docker-entrypoint.sh RUN chmod +x /app/docker-entrypoint.sh # Healthcheck to verify runtime capability HEALTHCHECK --interval=30s --timeout=5s --start-period=5s --retries=3 CMD java -version || exit 1 ENTRYPOINT ["/app/docker-entrypoint.sh"]
# Build container for the MyBatis repository (library) FROM maven:3.8.7-openjdk-11 AS builder WORKDIR /workspace # Prepare Maven wrapper and project files for dependency caching COPY pom.xml pom.xml COPY mvnw mvnw COPY .mvn .mvn # Ensure wrapper is executable RUN chmod +x mvnw # Pre-fetch dependencies (offline) to maximize caching RUN ./mvnw -B -Dlicense.skip=true -DskipTests dependency:go-offline || mvn -B -Dlicense.skip=true -DskipTests dependency:go-offline # Copy source and build the project COPY src src RUN ./mvnw -B -Dlicense.skip=true -DskipTests clean package # Runtime stage FROM eclipse-temurin:11-jre WORKDIR /app # Install curl for health checks RUN apt-get update && apt-get install -y curl && rm -rf /var/lib/apt/lists/* # Copy the built artifacts from the builder stage COPY --from=builder /workspace/target /app/target # Copy the entrypoint script and make it executable COPY docker-entrypoint.sh /app/docker-entrypoint.sh RUN chmod +x /app/docker-entrypoint.sh # Healthcheck to verify runtime capability (adjust URL/port if needed by entrypoint) HEALTHCHECK --interval=30s --timeout=5s --start-period=5s --retries=3 CMD curl -f http://localhost:8080/health || exit 1 ENTRYPOINT ["/app/docker-entrypoint.sh"]
# Build container for the MyBatis repository (library) FROM openjdk:11-jdk-slim AS builder WORKDIR /workspace # Copy project meta files first for dependency caching COPY pom.xml pom.xml COPY mvnw mvnw COPY .mvn .mvn # Ensure wrapper is executable RUN chmod +x mvnw # Pre-fetch dependencies (offline) to maximize caching RUN ./mvnw -B -Dlicense.skip=true -DskipTests dependency:go-offline # Copy sources and build the project COPY src src RUN ./mvnw -B -Dlicense.skip=true -DskipTests -Dgit.build.hook.skip=true clean package # Runtime stage FROM openjdk:11-jre-slim WORKDIR /app # Copy the built artifacts from the builder stage COPY --from=builder /workspace/target /app/target # Copy the entrypoint script and make it executable COPY docker-entrypoint.sh /app/docker-entrypoint.sh RUN chmod +x /app/docker-entrypoint.sh # Basic healthcheck to verify runtime availability HEALTHCHECK --interval=30s --timeout=5s --start-period=5s --retries=3 CMD java -version >/dev/null 2>&1 || exit 1 ENTRYPOINT ["/app/docker-entrypoint.sh"]
# Build container for the MyBatis repository (library)
# Builder stage: use a lightweight Debian-based image with OpenJDK 11 and manual Maven wiring
FROM debian:11-slim AS builder
ENV DEBIAN_FRONTEND=noninteractive
# Install JDK, curl and git (maven wrapper will download Maven as needed)
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
openjdk-11-jdk-headless \
ca-certificates \
curl \
git \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /workspace
# Copy pom and wrapper first for caching
COPY pom.xml pom.xml
COPY mvnw mvnw
COPY .mvn .mvn
RUN chmod +x mvnw
# Pre-fetch dependencies using the wrapper (license skip to reduce prompts)
RUN ./mvnw -B -Dlicense.skip=true -DskipTests dependency:go-offline
# Copy sources and build
COPY src src
RUN ./mvnw -B -Dlicense.skip=true -DskipTests -Dgit.build.hook.skip=true clean package
# Normalize the built jar name to app.jar for predictable entrypoint behavior
RUN bash -lc 'JAR=$(ls target/*.jar | head -n 1); [ -n "$JAR" ] && cp "$JAR" target/app.jar || true'
# Runtime stage
FROM debian:11-slim AS runtime
ENV JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64
ENV PATH="$JAVA_HOME/bin:$PATH"
WORKDIR /app
# Install JRE and curl for health checks
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
openjdk-11-jre-headless \
ca-certificates \
curl \
&& rm -rf /var/lib/apt/lists/*
# Copy built artifacts
COPY --from=builder /workspace/target /app/target
# Copy entrypoint script and ensure it is executable
COPY docker-entrypoint.sh /app/docker-entrypoint.sh
RUN chmod +x /app/docker-entrypoint.sh
# Basic healthcheck (adjust the health endpoint as needed by your app)
HEALTHCHECK --interval=30s --timeout=5s --start-period=5s --retries=3 CMD curl -f http://localhost:8080/health || exit 1
ENTRYPOINT ["/app/docker-entrypoint.sh"]
# Exclude VCS and build artifacts .git target **/target node_modules *.log .DS_Store *.iml .idea/ *.class
Status: VerifyBuild status: build_failed Actionable details - Failing step: Dockerfile: RUN ./mvnw -B -Dlicense.skip=true -DskipTests -Dgit.build.hook.skip=true clean package (builder 10/11) - Exit code: 1 - Exact error/context: Dockerfile:30 >>> RUN ./mvnw -B -Dlicense.skip=true -DskipTests -Dgit.build.hook.skip=true clean package [ERROR] Failed to execute goal org.apache.maven.plugins:maven-enforcer-plugin:3.6.2:enforce (enforce-java) on project mybatis [ERROR] Rule 1: org.apache.maven.enforcer.rules.version.RequireJavaVersion failed with message: [ERROR] Detected JDK /usr/lib/jvm/java-11-openjdk-amd64 is version 11.0.30 which is not in the allowed range [17,18),[21,22),[24,25),[25,26),[26,27). [ERROR] -> [Help 1] [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch. [ERROR] Re-run Maven using the -X switch to enable full debug logging. [ERROR] For more information about the errors, please read the following articles: [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException Dockerfile:30 28 | # Copy sources and build 29 | COPY src src 30 | >>> RUN ./mvnw -B -Dlicense.skip=true -DskipTests -Dgit.build.hook.skip=true clean package 31 | 32 | # Normalize the built jar name to app.jar for predictable entrypoint behavior - Build failure trace: ERROR: failed to build: failed to solve: process "/bin/sh -c ./mvnw -B -Dlicense.skip=true -DskipTests -Dgit.build.hook.skip=true clean package" did not complete successfully: exit code: 1 Environment details - Missing packages/files: No JRE found. Skipping Java certificates setup. (appears in log) #7 17.95 No JRE found. Skipping Java certificates setup. #8 29.49 No JRE found. Skipping Java certificates setup. - Detected JDK: /usr/lib/jvm/java-11-openjdk-amd64, version 11.0.30 - Allowed Java versions (enforcer rule): [17,18), [21,22), [24,25), [25,26), [26,27) Notes for remediation - The build fails due to Java version mismatch with Maven Enforcer Rule RequireJavaVersion. Use a JDK in one of the allowed ranges (e.g., 17.x, 21.x, 24.x, 25.x, or 26.x). - Ensure a JRE is present in the image to avoid “No JRE found” messages. - Build artifact name is expected to be app.jar; if the Maven packaging yields a different artifact name, the runtime copy/entrypoint may fail unless accounted for in the entrypoint script. - Full stack traces can be obtained by re-running Maven with -e and -X as suggested.
# Build container for the MyBatis repository (library)
# Builder stage: use a lightweight Debian-based image with OpenJDK 17 and manual Maven wiring
FROM debian:11-slim AS builder
ENV DEBIAN_FRONTEND=noninteractive
# Install JDK 17, curl (and minimal prerequisites)
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
openjdk-17-jdk-headless \
ca-certificates \
curl \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /workspace
# Copy pom and wrapper first for caching
COPY pom.xml pom.xml
COPY mvnw mvnw
COPY .mvn .mvn
RUN chmod +x mvnw
# Pre-fetch dependencies using the wrapper (license skip to reduce prompts)
RUN ./mvnw -B -Dlicense.skip=true -DskipTests dependency:go-offline
# Copy sources and build
COPY src src
RUN ./mvnw -B -Dlicense.skip=true -DskipTests -Dgit.build.hook.skip=true clean package
# Normalize the built jar name to app.jar for predictable entrypoint behavior
RUN set -e; JAR=$(ls target/*.jar 2>/dev/null | head -n 1); if [ -n "$JAR" ]; then cp "$JAR" target/app.jar; fi
# Runtime stage
FROM debian:11-slim AS runtime
ENV JAVA_HOME=/usr/lib/jvm/java-17-openjdk-amd64
ENV PATH="$JAVA_HOME/bin:$PATH"
WORKDIR /app
# Install JRE and curl for health checks
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
openjdk-17-jre-headless \
ca-certificates \
curl \
&& rm -rf /var/lib/apt/lists/*
# Copy built artifacts
COPY --from=builder /workspace/target /app/target
# Copy entrypoint script and ensure it is executable
COPY docker-entrypoint.sh /app/docker-entrypoint.sh
RUN chmod +x /app/docker-entrypoint.sh
# Entry point to launch the application
ENTRYPOINT ["/app/docker-entrypoint.sh"]
Summary: - Exact error message and exit code - "Could not find or initialise a local git repository. A repository is required. -> [Help 1]" - exit code: 1 - Failing command/step - RUN ./mvnw -B -Dlicense.skip=true -DskipTests -Dgit.build.hook.skip=true clean package - Dockerfile: line 29 (builder step 10/11) - Missing packages or files mentioned - Missing local git repository (.git) in the build context; the git-build-hook-maven-plugin requires an initialized git repository to be present. - Version mismatch/info - git-build-hook-maven-plugin version: 3.6.0 - Java environment shown earlier includes OpenJDK 17 (openjdk-17-jdk-headless/openjdk-17-jre-headless) and Debian 11 base, but the root cause is the missing git repo, not a version mismatch.
# Build container for the MyBatis repository (library)
# Builder stage: use a lightweight Debian-based image with OpenJDK 17 and manual Maven wiring
FROM debian:11-slim AS builder
ENV DEBIAN_FRONTEND=noninteractive
# Install JDK 17, curl (and minimal prerequisites)
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
openjdk-17-jdk-headless \
ca-certificates \
curl \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /workspace
# Copy pom and wrapper first for caching
COPY pom.xml pom.xml
COPY mvnw mvnw
COPY .mvn .mvn
RUN chmod +x mvnw
# Initialize a temporary git repository to satisfy git-build-hook during build
RUN git init \
&& git config user.email "build@example.com" \
&& git config user.name "BuildAgent" \
&& git add -A \
&& git commit -m "initial commit" --allow-empty
# Pre-fetch dependencies using the wrapper (license skip to reduce prompts)
RUN ./mvnw -B -Dlicense.skip=true -DskipTests dependency:go-offline
# Copy sources and build
COPY src src
RUN ./mvnw -B -Dlicense.skip=true -DskipTests -Dgit.build.hook.skip=true clean package
# Normalize the built jar name to app.jar for predictable entrypoint behavior
RUN set -e; JAR=$(ls target/*.jar 2>/dev/null | head -n 1); if [ -n "$JAR" ]; then cp "$JAR" target/app.jar; fi
# Runtime stage
FROM debian:11-slim AS runtime
ENV JAVA_HOME=/usr/lib/jvm/java-17-openjdk-amd64
ENV PATH="$JAVA_HOME/bin:$PATH"
WORKDIR /app
# Install JRE and curl for health checks
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
openjdk-17-jre-headless \
ca-certificates \
curl \
&& rm -rf /var/lib/apt/lists/*
# Copy built artifacts
COPY --from=builder /workspace/target /app/target
# Copy entrypoint script and ensure it is executable
COPY docker-entrypoint.sh /app/docker-entrypoint.sh
RUN chmod +x /app/docker-entrypoint.sh
# Entry point to launch the application
ENTRYPOINT ["/app/docker-entrypoint.sh"]
Concerns: Builder stage calls git init/commit but git is not installed in the builder image, which will cause the build to fail., No explicit CMD; relies on docker-entrypoint.sh, which is fine, but ensure it handles absence of a runnable main jar gracefully when used as a library.
#!/bin/sh set -e # Try to locate the runnable jar. Prefer /app/target/app.jar; fall back to any jar in /app/target JAR_PATH="/app/target/app.jar" if [ ! -f "$JAR_PATH" ]; then JAR_PATH=$(ls -1 /app/target/*.jar 2>/dev/null | head -n 1) fi if [ -z "$JAR_PATH" ]; then echo "No runnable JAR found in /app/target. Exiting." exit 1 fi exec java -jar "$JAR_PATH" "$@"
Concerns: Builder stage uses 'git init' and related git operations but git is not installed in the builder image, causing the build to fail at that step., JAVA_HOME path is assumed to be /usr/lib/jvm/java-17-openjdk-amd64; verify this path exists in the Debian 11 OpenJDK packages used (could differ between JDK/JRE installations)., Potential dependency on docker-entrypoint.sh existing and being executable; ensure the file is present in the repo and has proper shebang and permissions.
# Build container for the MyBatis repository (library)
# Builder stage: use a lightweight Debian-based image with OpenJDK 17 and manual Maven wiring
FROM debian:11-slim AS builder
ENV DEBIAN_FRONTEND=noninteractive
# Install JDK 17, curl, and git (to satisfy git hooks)
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
openjdk-17-jdk-headless \
ca-certificates \
curl \
git \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /workspace
# Copy pom and wrapper first for caching
COPY pom.xml pom.xml
COPY mvnw mvnw
COPY .mvn .mvn
RUN chmod +x mvnw
# Initialize a temporary git repository to satisfy git-build-hook during build
RUN git init \
&& git config user.email "build@example.com" \
&& git config user.name "BuildAgent" \
&& git add -A \
&& git commit -m "initial commit" --allow-empty
# Pre-fetch dependencies using the wrapper (license skip to reduce prompts)
RUN ./mvnw -B -Dlicense.skip=true -DskipTests dependency:go-offline
# Copy sources and build
COPY src src
RUN ./mvnw -B -Dlicense.skip=true -DskipTests -Dgit.build.hook.skip=true clean package
# Normalize the built jar name to app.jar for predictable entrypoint behavior
RUN set -e; JAR=$(ls target/*.jar 2>/dev/null | head -n 1); if [ -n "$JAR" ]; then cp "$JAR" target/app.jar; fi
# Runtime stage
FROM debian:11-slim AS runtime
ENV JAVA_HOME=/usr/lib/jvm/java-17-openjdk-amd64
ENV PATH="$JAVA_HOME/bin:$PATH"
WORKDIR /app
# Install JRE and curl for health checks
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
openjdk-17-jre-headless \
ca-certificates \
curl \
tini \
&& rm -rf /var/lib/apt/lists/*
# Copy built artifacts
COPY --from=builder /workspace/target /app/target
# Copy entrypoint script and ensure it is executable
COPY docker-entrypoint.sh /app/docker-entrypoint.sh
RUN chmod +x /app/docker-entrypoint.sh
# Ensure docker-entrypoint.sh exists in final image
RUN [ -f /app/docker-entrypoint.sh ]
# Entry point to launch the application
ENTRYPOINT ["tini", "--", "/app/docker-entrypoint.sh"]
#!/bin/sh set -e # Try to locate the runnable jar. Prefer /app/target/app.jar; fall back to any jar in /app/target JAR_PATH="/app/target/app.jar" if [ ! -f "$JAR_PATH" ]; then JAR_PATH=$(ls -1 /app/target/*.jar 2>/dev/null | head -n 1) fi if [ -z "$JAR_PATH" ]; then echo "No runnable JAR found in /app/target. Exiting." exit 1 fi exec java -jar "$JAR_PATH" "$@"
Concerns: Environment variable expansion for PATH in the runtime stage uses a literal reference to JAVA_HOME in PATH, which may not expand as intended in all shells. Consider setting PATH explicitly to the actual bin path, e.g., PATH=/usr/lib/jvm/java-17-openjdk-amd64/bin:${PATH}., Relies on docker-entrypoint.sh existing in the repository; if it is missing or not executable, the image build will fail., Dockerfile assumes the built artifact is /app/target/app.jar after build; if the build produces multiple jars, or the naming changes, the runtime copy may not align with the entrypoint expectations.
Smoke [PASS]: test -f /app/target/app.jar
Smoke [PASS]: java -version
Smoke [PASS]: test -d /app/target && [ -n "$(ls -A /app/target | head -n 1)" ]