Skip to content

Conversation

@sindre-nistad
Copy link
Contributor

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;

  • 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.

@sindre-nistad sindre-nistad requested a review from a team as a code owner February 14, 2025 09:12
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.
@sindre-nistad sindre-nistad force-pushed the improve-container-images branch from 9235f95 to 0b56f52 Compare February 14, 2025 12:25
@sindre-nistad sindre-nistad self-assigned this Feb 14, 2025
@sebastianvitterso sebastianvitterso changed the title [refactor] Utilize multistage builds to improve caching and compatibility refactor: utilize multistage builds to improve caching and compatibility Feb 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants