Maven失败解决:无法计算缓存键:无法计算ref的校验和

问题描述 投票:0回答:1

我想使用 docker 作为我试图在 AWS 上托管的 java spring boot 后端。但我似乎正在努力寻找以下问题的解决方案

=> ERROR [stage-1 3/3] COPY --from=build home/ec2-user/.mvn/wrapper/maven-wrapper.jar ./                          0.0s
------
 > [stage-1 3/3] COPY --from=build home/ec2-user/.mvn/wrapper/maven-wrapper.jar ./:
------
Dockerfile:24
--------------------
  22 |
  23 |     # Copy the compiled JAR file from the build stage
  24 | >>> COPY --from=build home/ec2-user/.mvn/wrapper/maven-wrapper.jar ./
  25 |
  26 |     # Expose the port that the backend will run on
--------------------
ERROR: failed to solve: failed to compute cache key: failed to calculate checksum of ref 88fa4e79-193c-494c-9b78-a51635c02f26::sum3xp0gj6qesjumgreviomra: failed to walk /var/lib/docker/tmp/buildkit-mount2174057775/home/ec2-user/.mvn/wrapper: lstat /var/lib/docker/tmp/buildkit-mount2174057775/home/ec2-user/.mvn/wrapper: no such file or directory

这是我的 docker 文件

# Stage 1: Build Stage
FROM maven:3.8.4-openjdk-17 AS build

# Set the working directory in the container
WORKDIR /home/ec2-user

# Copy the Maven wrapper .jar file into the container
COPY mvnw ./
COPY mvnw.cmd ./
COPY .mvn ./

# Copy the project files and build the application
COPY pom.xml ./
COPY src/main ./src
RUN mvn clean install

# Stage 2: Runtime Stage
FROM openjdk:17

# Set the working directory in the container
WORKDIR /home/ec2-user

# Copy the compiled JAR file from the build stage
COPY --from=build home/ec2-user/.mvn/wrapper/maven-wrapper.jar ./

# Expose the port that the backend will run on
EXPOSE 3000

# Health check endpoint (add appropriate logic in your application)
HEALTHCHECK --interval=30s --timeout=10s CMD curl --fail http://localhost:3000/health || exit 1

# Command to run your Java application
CMD ["java", "-jar", "maven-wrapper.jar"]

我尝试使用不同的命令运行它,并尝试从不同的文件夹运行复制命令。

docker build --no-cache --target build -t libarter-be-aws:build-stage .
This command works but later down the line it tells me this:
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  0.609 s
[INFO] Finished at: 2024-04-16T11:13:13Z
[INFO] ------------------------------------------------------------------------
[ERROR] No goals have been specified for this build. You must specify a valid lifecycle phase or a goal in the format <plugin-prefix>:<goal> or <plugin-group-id>:<plugin-artifact-id>[:<plugin-version>]:<goal>. Available lifecycle phases are: validate, initialize, generate-sources, process-sources, generate-resources, process-resources, compile, process-classes, generate-test-sources, process-test-sources, generate-test-resources, process-test-resources, test-compile, process-test-classes, test, prepare-package, package, pre-integration-test, integration-test, post-integration-test, verify, install, deploy, pre-clean, clean, post-clean, pre-site, site, post-site, site-deploy. -> [Help 1]
[ERROR]
[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]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/NoGoalSpecifiedException

我尝试更改 pom 文件,但同样没有任何变化,无论我采取什么方法,我都遇到了两个不同的错误。

我只想构建它并让它运行,这正是我所需要的。

spring amazon-web-services docker maven dockerfile
1个回答
0
投票

我也有同样的问题。你解决了吗?

© www.soinside.com 2019 - 2024. All rights reserved.