Remove the installation of yarn in the `Dockerfile (it's included in the Node images now)
The previous Dockerfile would only work when you were running the service with docker-compose since you had a shared volume between your host machine and the container, but if you just tried to build the image and then tried to run it it would fail because in the build process no source code was moved into the container.
Switched the node image to the latest LTS slim image.
It's best practice to have the apt-get update and apt-get install on the same line concatenated with && to take advantage of docker caching and proper cache-busting. Refer to the Run section here.
Now you can develop without having to install anything locally (e.g. node_modules, node, yarn, etc.) except maybe git and a text editor.
WHY?
The official docker NodeJS images include
yarn
so there is no longer a need to install it in theDockerfile
References:WHAT?
yarn
in the `Dockerfile (it's included in the Node images now)Dockerfile
would only work when you were running the service withdocker-compose
since you had a shared volume between your host machine and the container, but if you just tried to build the image and then tried to run it it would fail because in the build process no source code was moved into the container.node
image to the latest LTS slim image.apt-get update
andapt-get install
on the same line concatenated with&&
to take advantage of docker caching and proper cache-busting. Refer to theRun
section here.node_modules
,node
,yarn
, etc.) except maybegit
and a text editor.