如何设置多路径docker build复制文件的正确路径?

时间:2018-10-03 09:10:09

标签: docker zeit-now

这是Dockerfile:

if ! echo $JAVA_HOME | grep 64 ; then
  echo "No valid JRE installation found in $JAVA_HOME to match ARCH $ARCH or $JAVA_HOME not set properly."; exit 1
fi

使用命令'docker build'在本地计算机上构建映像时。 -正常,但是当我尝试将项目放入zeit时,出现下一个错误:

# tag block to refering
FROM node:alpine as builder
WORKDIR /home/server
COPY package.json .
RUN npm install
COPY . .
CMD ["npm", "run", "build"]

# on second step use another core image
FROM nginx

# copy files builded on previous step
COPY --from=builder /home/server/build usr/share/nginx/html

可能是什么?谢谢。

1 个答案:

答案 0 :(得分:1)

Your first stage doesn't actually RUN the build command,因此构建目录为空。将CMD行更改为RUN行。

一个技巧:docker build序列的每一行都产生自己的中间层,并且每一层都是可运行的Docker映像。您会看到类似

的输出
Step 6/8: CMD ["npm", "run", "build"]
 ---> Running in 02071fceb21b
 ---> f52f38b7823e

最后一个数字是有效的Docker映像ID,您可以

docker run --rm -it f52f38b7823e sh

查看该图像中的内容。

相关问题