Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

One solution in Docker is multistage builds where A and B can be separated into intermediate images with results copied into C.

A pattern that I like to use is two multistage build Dockerfiles- `dev` and `prod`.

The `dev` image has 2 stages. The first stage copies only files required by the package manager, such as `package.json` into another directory using a combination of `find` and `cp --parents`, then restores dependencies. The second stage copies the dependencies from the first stage and overlays source code. The `dev` image is then instantiated to run all tests.

The `prod` image also has 2 stages. The first stage starts with the `dev` image and publishes a production bundle to a directory. The second stage starts with a clean image and copies the production bundle from the first stage.



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: