use multi-stage build to minimize size of Docker image #346
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The changes in this commit reduce the Docker image size from >1 GB to 205 MB. Docker multi-stage builds were used to achieve this. In the first stage, the core ta-lib library is compiled, and the Python ta-lib package is installed. Then, in the second stage, the compiled core ta-lib library and the Python wheel files are copied over and installed. The second stage also uses the
python:VERSION-slim
Docker image, which is much smaller than thepython:VERSION
image, because it does not include any compilers or other software not necessary at runtime.The build and run procedure is unchanged. Use
docker build --tag ta-lib .
to build anddocker run --rm -it ta-lib bash
to run.Another change introduced by the commit is the option of skipping testing during image building. By default, testing is not skipped, but it can be skipped with
docker build --tag ts-lib --build-arg RUN_TESTS=0 .
.I uploaded a built image to https://hub.docker.com/r/kaczmarj/ta-lib:
docker pull kaczmarj/ta-lib