refactor: utilize multistage builds to improve caching and compatibility#271
Open
sindre-nistad wants to merge 1 commit intomainfrom
Open
refactor: utilize multistage builds to improve caching and compatibility#271sindre-nistad wants to merge 1 commit intomainfrom
sindre-nistad wants to merge 1 commit intomainfrom
Conversation
The main changes here are; * using multi-stage builds for better caching and smaller images * explicitly listing the files that should be included / "COPY"able into the containers For the API, I moved the tests outside the `src` folder. That way, we do not include the tests in the finished image. Since we use multi-stage builds, we can install the necessary compilers for running on ARM. The compilers are not part of the "production" image, and we don't need to worry about them taking up more space in the image layers. I also created a user (similar to what's done in `nginx`) so that we can run the tests without running the container as root. When only installing the necessary packages, I noticed that `click` is not explicitly defined, so it wasn't included in `site-packages`. By explicitly listing it in `pyproject.toml`, that issue is resolved.
9235f95 to
0b56f52
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Why is this pull request needed?
Gives us smaller images, and reduces the risk for adding files which should not be included
What does this pull request change?
The main changes here are;
For the API, I moved the tests outside the
srcfolder. That way, we do not include the tests in the finished image. Since we use multi-stage builds, we can install the necessary compilers for running on ARM. The compilers are not part of the "production" image, and we don't need to worry about them taking up more space in the image layers.I also created a user (similar to what's done in
nginx) so that we can run the tests without running the container as root.When only installing the necessary packages, I noticed that
clickis not explicitly defined, so it wasn't included insite-packages. By explicitly listing it inpyproject.toml, that issue is resolved.