0

我尝试了 DOCKER_BUILDKIT=1,但如果源代码发生更改,仍然会下载 mvn 库。我做错了什么?请注意多个 pom.xml 文件。

# syntax=docker/dockerfile:experimental
FROM maven:3-eclipse-temurin-11 AS build

WORKDIR /workdir

COPY pom.xml /workdir
COPY sub_project/pom.xml /workdir/sub_project/
COPY src /workdir/src

COPY config/settings.xml /root/.m2/settings.xml

RUN --mount=type=cache,target=/root/.m2 mvn clean package  -Dmaven.test.skip

FROM eclipse-temurin:11.0.13_8-jdk-focal AS run
<other code>

我这样运行

COMPOSE_DOCKER_CLI_BUILD=1 DOCKER_BUILDKIT=1 docker-compose build my-project

4

0 回答 0