# syntax=docker/dockerfile:1 # Stage 1: Build the project from source using Maven with a Java 21 runtime FROM maven:3.9.3-eclipse-temurin-21 AS builder WORKDIR /workspace # Copy the entire repository and build COPY . . RUN mvn -B -DskipTests package # Stage 2: Create a lightweight runtime image FROM eclipse-temurin:21-jre WORKDIR /app # Copy built artifacts from the builder stage (include all project content for potential runtime inspection) COPY --from=builder /workspace /app # Provide a lightweight, safe default command. # This container will print a confirmation message and then stay alive. CMD ["sh","-lc","echo 'Activiti project built in container.' && tail -f /dev/null"]
# syntax=docker/dockerfile:1 FROM openjdk:21-jdk-slim AS builder WORKDIR /workspace # Install Maven and dependencies required for build RUN apt-get update && apt-get install -y --no-install-recommends \ curl ca-certificates unzip \ && rm -rf /var/lib/apt/lists/* ENV MAVEN_VERSION=3.9.3 # Install Maven RUN mkdir -p /usr/share/maven \ && curl -fsSLo /tmp/maven.tar.gz https://archive.apache.org/dist/maven/maven-3/3.9.3/binaries/apache-maven-3.9.3-bin.tar.gz \ && tar -xzf /tmp/maven.tar.gz -C /usr/share/maven --strip-components=1 \ && ln -s /usr/share/maven/bin/mvn /usr/bin/mvn ENV MAVEN_HOME=/usr/share/maven ENV PATH="$MAVEN_HOME/bin:$PATH" COPY . . RUN mvn -B -DskipTests package FROM openjdk:21-jre-slim WORKDIR /app COPY --from=builder /workspace /app CMD ["sh","-lc","echo 'Activiti project built from source.' && tail -f /dev/null"]
# syntax=docker/dockerfile:1
# Stage 1: Build the project from source using Maven with a Java 21 JDK
FROM eclipse-temurin:21-jdk AS builder
WORKDIR /workspace
# Install dependencies needed for Maven and building
RUN apt-get update && apt-get install -y --no-install-recommends \
curl ca-certificates unzip tar \
&& rm -rf /var/lib/apt/lists/*
ENV MAVEN_VERSION=3.9.3
# Install Maven
RUN mkdir -p /usr/share/maven \
&& curl -fsSLo /tmp/maven.tar.gz https://archive.apache.org/dist/maven/maven-3/${MAVEN_VERSION}/binaries/apache-maven-${MAVEN_VERSION}-bin.tar.gz \
&& tar -xzf /tmp/maven.tar.gz -C /usr/share/maven --strip-components=1 \
&& ln -s /usr/share/maven/bin/mvn /usr/bin/mvn
ENV MAVEN_HOME=/usr/share/maven
ENV PATH="$MAVEN_HOME/bin:$PATH"
# Copy the source code and build the project from source
COPY . .
RUN mvn -B -DskipTests package
# Stage 2: Runtime image
FROM eclipse-temurin:21-jre
WORKDIR /app
# Copy built artifacts from the builder stage
COPY --from=builder /workspace /app
# Default command to keep the container alive and indicate build success
CMD ["bash","-lc","echo 'Activiti multi-module project built from source' && tail -f /dev/null"]
# Ignore git and local environment files .git .gitignore .dockerignore Dockerfile .docker-compose*.yaml target **/target/ **/build/ node_modules vendor *.log *.tmp *.bak *.md
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 activiti-parent:
[ERROR] Rule 0: org.apache.maven.enforcer.rules.version.RequireJavaVersion failed with message:
[ERROR] Detected JDK /opt/java/openjdk is version 21.0.10 which is not in the allowed range [25,).
[ERROR] -> [Help 1]
...
- Docker build failure: failed to solve: process "/bin/sh -c mvn -B -DskipTests package" did not complete successfully: exit code: 1
- Failing command/step
- RUN mvn -B -DskipTests package (Dockerfile:25), i.e., builder step 6/6
- Missing packages or files mentioned
- None explicitly mentioned as missing. The apt-get step installs unzip and related tools; no missing-file errors shown.
- Version mismatch info
- Enforcer requires Java version >= 25; detected JDK version is 21.0.10 (in /opt/java/openjdk).# syntax=docker/dockerfile:1
# Stage 1: Build the project from source using Maven with a Java 25 JDK
FROM eclipse-temurin:25-jdk AS builder
WORKDIR /workspace
# Install dependencies needed for Maven and building
RUN apt-get update && apt-get install -y --no-install-recommends \
curl ca-certificates unzip tar \
&& rm -rf /var/lib/apt/lists/*
ENV MAVEN_VERSION=3.9.3
# Install Maven
RUN mkdir -p /usr/share/maven \
&& curl -fsSLo /tmp/maven.tar.gz https://archive.apache.org/dist/maven/maven-3/${MAVEN_VERSION}/binaries/apache-maven-${MAVEN_VERSION}-bin.tar.gz \
&& tar -xzf /tmp/maven.tar.gz -C /usr/share/maven --strip-components=1 \
&& ln -s /usr/share/maven/bin/mvn /usr/bin/mvn
ENV MAVEN_HOME=/usr/share/maven
ENV PATH="$MAVEN_HOME/bin:$PATH"
# Copy the source code and build the project from source
COPY . .
RUN mvn -B -DskipTests package
# Stage 2: Runtime image
FROM eclipse-temurin:25-jre
WORKDIR /app
# Copy built artifacts from the builder stage
COPY --from=builder /workspace /app
# Default command to keep the container alive and indicate build success
CMD ["bash","-lc","echo 'Activiti multi-module project built from source' && tail -f /dev/null"]
Concerns: The final image uses a placeholder CMD that only echoes a message and tails /dev/null; the container won't run the built artifact by default. Consider wiring it to run the produced jar or provide a proper entrypoint., CMD uses bash, which may not be present on all JRE images (some minimal runtimes provide sh). Consider using sh -c or an explicit entrypoint script to improve portability. Smoke [PASS]: find /app -name "*.jar" -type f -print -quit Smoke [PASS]: java -version