no entry file inside docker image
andrewkslv opened this issue · 3 comments
andrewkslv commented
Docker can't find server.js file inside the image. The way to reproduce:
$ node tools/publish.js foobar
$ docker run -p 8080:8080 api
response:
Error: Cannot find module '/usr/src/app/build/server.js'
at Function.Module._resolveFilename (module.js:527:15)
at Function.Module._load (module.js:453:25)
at Function.Module.runMain (module.js:665:10)
at startup (bootstrap_node.js:201:16)
at bootstrap_node.js:626:3
koistya commented
Try running this:
$ docker-compose run --rm --no-deps api yarn # Install Node.js dependencies
$ docker-compose run --rm --no-deps api yarn build # Compile the app into ./build
$ docker build --no-cache --tag api . # Build the production "api" image
$ docker run --rm -p 8080:8080 api # Check if it works
$ docker run --rm api ls /usr/src/app/build # Show the files inside the image
koistya commented
@eclipticwld the current setup expects you to build the app first, then run docker build
command that copies all the compiled output into the image (COPY . .
), see Dockerfile
. It is possible though to tweak Dockerfile
so that it would build the app during image compilation and then prune non-production dependencies. Please, let me know if the later workflow works better for you.
andrewkslv commented
Thank you @koistya! That was helpful to move forward.