0

Here is Dockerfile:

# 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

When image is builded on local machine with command 'docker build .' - it works fine, but when I trying to put the project to zeit I get next error:

Step 8/8 : COPY --from=builder /home/server/build usr/share/nginx/html
> COPY failed: stat   /var/lib/docker/overlay2/a114ae6aae803ceb3e3cffe48fa1694d84d96a08e8b84c4974de299d5fa35543/merged/home/server/build: no such file or directory

What it can be? Thanks.

Gordienko R.
  • 331
  • 4
  • 16

1 Answers1

1

Your first stage doesn't actually RUN the build command, so the build directory is empty. Change the CMD line to a RUN line.

One tip: each separate line of the docker build sequence produces its own intermediate layer, and each layer is a runnable Docker image. You'll see output like

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

That last number is a valid Docker image ID and you can

docker run --rm -it f52f38b7823e sh

to see what's in that image.

David Maze
  • 130,717
  • 29
  • 175
  • 215
  • Yeap, you are right. It works on local machine because I already build my project locally and build folder just copied with other files. Thank you. – Gordienko R. Oct 03 '18 at 11:38