Dockerfile
# Dockerfile
FROM node:12.11.1
# update and install dependency
RUN apt-get update
# copy / target Main Folder
COPY . /opt/frontend
# work in folder
WORKDIR /opt/frontend
# install dependency
RUN npm install
# set app serving to permissive / assigned
# if you do not specify host, you cannot connect from the host
ENV HOST 0.0.0.0
# output port
EXPOSE 3000
CMD [ "npm", "run", "dev" ]
Error:
npm ERR! code ENOENT
npm ERR! syscall open
npm ERR! path /opt/frontend/package.json
npm ERR! errno -2
npm ERR! enoent ENOENT: no such file or directory, open '/opt/frontend/package.json'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent
npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2021-11-15T14_31_01_250Z-debug.log
the build was succesful and read about this error that is package.json is not copy over, but isit this line already copy the main frontend folder everything over ?
# copy / target Main Folder
COPY . /opt/frontend
what i missout ? my github : https://github.com/differentMonster/nuxt3-troisjs
CodePudding user response:
Your are building the image with wrong context. Try this:
cd frontend
docker build . -f ./docker/dev/Dockerfile -t your_app_name
Or
docker build ./frontend -f ./docker/dev/Dockerfile -t your_app_name
You need to specify a context path