Copying a generated folder in Dockerfile

  docker, dockerfile, node.js, yarnpkg

I’m trying to use docker in my hosted node.js application.

The command "yarn build" generates a folder of static assets for my application. It works fine locally without Docker but when I deploy with Docker I get the following error:

Error: ENOENT: no such file or directory, stat '/usr/src/app/build/index.html'

Here’s my current Dockerfile:

FROM node:alpine

# Create app directory
WORKDIR /usr/src/app

# Install app dependencies
COPY package.json .
COPY yarn.lock .

RUN yarn

# Bundle app source
CMD [ "yarn", "build" ]
COPY . .

EXPOSE 80

CMD ["node", "server.js"]

Could I get a pointer as to where I might be going wrong?

Source: Docker Questions

LEAVE A COMMENT