Jenkins构建异常,Dockerfile中ADD或COPY及相对路径
制品构建前后端异常
#前端
09:45:53 + docker build -t hubtest.......com.cn/duty_record/......-web-01:origin-master-20 -f vue/script/Dockerfile vue/script
09:45:54 Sending build context to Docker daemon 2.048kB09:45:54 Step 1/3 : FROM nginx:latest
09:45:54 ---> 2002d33a54f7
09:45:54 Step 2/3 : COPY dist /usr/share/nginx/html/web
09:45:54 COPY failed: stat /var/lib/docker/tmp/docker-builder011699567/dist: no such file or directory#后端
10:40:14 + docker build - .......com.cn/duty_record/duty_record-webapi-01:origin-master-19 -f boot/script/Dockerfile boot/script
10:40:14 Sending build context to Docker daemon 2.048kB10:40:14 Step 1/9 : FROM eclipse-temurin:8-jdk-centos7
10:40:14 ---> 1018a340787f
10:40:14 Step 2/9 : ENV TZ Asia/Shanghai
10:40:14 ---> Running in 125cdd73212e
10:40:14 Removing intermediate container 125cdd73212e
10:40:14 ---> 42e25110dbf9
10:40:14 Step 3/9 : ADD ${WORKSPACE}/target/duty-record-0.0.1.jar server.jar
10:40:14 ADD failed: stat /var/lib/docker/tmp/docker-builder402861475/target/duty-record-0.0.1.jar: no such file or directory
- Dockerfile中ADD或COPY命令后面的路径为相对于上下文的路径
- 将Dockerfile放在项目的script后,执行build命令后认为当前路径为vue/script 和boot/script 在这个当前路径下找不到前端需要的dist文件夹内容,及后端需要target内容。
- 将Dockerfile移动到项目文件夹下,同时注意修改前端后pipelineCfg.json中的docker_file路径。
- 【或】增加命令,将dist文件与target中jar包移动到当前目录下。
欢迎关注公众号:有点建树,做更多交流。