Assembling the sources

In this step, we make sure all source files and other artifacts needed to successfully build the application are part of the image. Here, we mainly use the two keywords of the DockerfileCOPY and ADD. Initially, the structure of the source inside the image should look exactly the same as on the host, to avoid any build problems. Ideally, you would have a single COPY command that copies all of the root project folder from the host into the image. The corresponding Dockerfile snippet could then look as simple as this:

WORKDIR /app
COPY . .
Don't forget to also provide a .dockerignore file located in the project root folder, which lists all the files and (sub-) folders of the project root folder that should not be part of the build context.

As mentioned earlier, you can also use the ADD keyword to download sources and other artifacts into the Docker image that are not located in the build context but somewhere reachable by a URI, as shown here:

ADD http://example.com/foobar ./ 

This would create a foobar folder in the image's working folder and copy all the contents from the URI.