Copying project files

Next, we need to copy in our project code into our container. We will use the COPY instruction, which has the following signature:

COPY [--chown=<user>:<group>] <src>... <dest>

src is the path on the host machine where files will be copied from. The src path will be resolved against the context, which is a directory we can specify when we run docker build.

dest is the path inside the container where the files are to be copied to. The dest path can be either absolute or relative. If relatively, it will be resolved against the WORKDIR.

Below the FROM instruction, add a WORKDIR and COPY instruction:

WORKDIR /root/ COPY . .

This simply copies all the files from the context to the /root/ inside the container.

Get Building Enterprise JavaScript Applications now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.