mmazzarolo / react-native-universal-monorepo

React Native boilerplate supporting multiple platforms: Android, iOS, macOS, Windows, web, browser extensions, Electron.
MIT License
1.7k stars 150 forks source link

Docker run cannot find package json #38

Open gyi123 opened 2 years ago

gyi123 commented 2 years ago

Hi, I was able to run yarn web:start from CMD. However when I try to run this in Docker. I got package.json not found error. Here is the docker file:

FROM node:16.13.0-alpine

set working directory

WORKDIR / COPY ["yarn.lock", "package.json", "./"] RUN yarn reset:unix RUN yarn

add app

COPY . ./

start app

CMD ["yarn", "web:start"]

After successful docker build, I try to run in docker desktop: docker run -p:3000:3000 myimage I got this error: yarn run v1.22.15 $ yarn workspace @my-app/web start $ craco start /node_modules/find-root/index.js:19 throw new Error('package.json not found in path') ^

Error: package.json not found in path at findRoot (/node_modules/find-root/index.js:19:11) at findRoot (/node_modules/find-root/index.js:28:10) at findRoot (/node_modules/find-root/index.js:28:10) at findRoot (/node_modules/find-root/index.js:28:10) at findRoot (/node_modules/find-root/index.js:28:10)

Any idea on this? Thanks for the help

gyi123 commented 2 years ago

I think I solved it. My docker file is wrong. need to use WORKDIR /repo then COPY