收藏
回答

微信云托管docker部署mvn运行失败?我本地构建没有任何问题

报错说:

[2023-02-28 14:09:10]  ---> 049b78eafa88
[2023-02-28 14:09:10] Step 6/16 : COPY settings.xml pom.xml /app/
[2023-02-28 14:09:10]  ---> ed90bacb1c9b
[2023-02-28 14:09:10] Step 7/16 : COPY settings.xml /root/.m2/
[2023-02-28 14:09:11]  ---> 3e704fe983df
[2023-02-28 14:09:11] Step 8/16 : RUN mvn -s /app/settings.xml -f /app/pom.xml clean package -X
[2023-02-28 14:09:11]  ---> Running in 4f89bebe9e19
[2023-02-28 14:09:11] ls: cannot access '/usr/bin/mvn': Operation not permitted
[2023-02-28 14:09:11] Error: Could not find or load main class org.codehaus.plexus.classworlds.launcher.Launcher
[2023-02-28 14:09:11] Caused by: java.lang.ClassNotFoundException: org.codehaus.plexus.classworlds.launcher.Launcher
[2023-02-28 14:09:11] The command '/bin/sh -c mvn -s /app/settings.xml -f /app/pom.xml clean package -X' returned a non-zero code: 1
[2023-02-28 14:09:12] [Pipeline] }


我的dockerfile定义如下:


FROM maven:3.8.3-openjdk-17-slim as build

# 指定构建过程中的工作目录
WORKDIR /app

# 切换为 root 用户
USER root

# 将src目录下所有文件,拷贝到工作目录中src目录下(.gitignore/.dockerignore中文件除外)
COPY src /app/src

RUN chmod a+rwx /usr/bin/mvn
# 将pom.xml文件,拷贝到工作目录下
COPY settings.xml pom.xml /app/
COPY settings.xml /root/.m2/

# 执行代码编译命令
# 自定义settings.xml, 选用国内镜像源以提高下载速度
RUN mvn -s /app/settings.xml -f /app/pom.xml clean package -X

...
回答关注问题邀请回答
收藏
登录 后发表内容