The Pyrrha (created by Prometeo) solution application for determining thresholds in toxin exposure measured by the sensor device and sent to the cloud from the smartphone carried by the firefighters.
Even if the RedHat base image is supposed to be free of problems, I noticed that there are some key issues related to its usage:
It's a fully-fledged operating system, so it has plenty of packages which we will never use
Since it's an operating system, the final size of the image is way bigger than what we could expect
Snyk throws different results on the scan than the RedHat website
Changes
Due to that, I decided to implement the following changes:
Use a multi-stage build approach
There is no need of having the full operating system on the final image, even if we need some packages for compiling our dependencies. Due to that, we compile the dependencies of our project in a first stage within the context of a venv and then we use those already compiled dependencies for running the application.
Use a custom non-root user
I know the RedHat image uses it's 1001 user by default, but I think it's better if we control in every moment which is the user that we're using and which permissions does it have over which directories.
Of course, using a root user isn't an option.
Run the WSGI Server within the context of a venv
We don't want to use all the system-dependencies but just the ones that we explicitly installed and provided during the build step.
Improves
Old Image
New Image
Size
1.06 GB
332 MB
Dependencies[^1]
429
116
Vulnerabilities[^1]
805
48
Also, the previous implemented cache capabilities will remain.
Context
Even if the RedHat base image is supposed to be free of problems, I noticed that there are some key issues related to its usage:
Changes
Due to that, I decided to implement the following changes:
Use a multi-stage build approach
There is no need of having the full operating system on the final image, even if we need some packages for compiling our dependencies. Due to that, we compile the dependencies of our project in a first stage within the context of a
venv
and then we use those already compiled dependencies for running the application.Use a custom non-root user
I know the RedHat image uses it's
1001
user by default, but I think it's better if we control in every moment which is the user that we're using and which permissions does it have over which directories.Of course, using a root user isn't an option.
Run the WSGI Server within the context of a
venv
We don't want to use all the system-dependencies but just the ones that we explicitly installed and provided during the build step.
Improves
Also, the previous implemented cache capabilities will remain.
[^1]:
docker scan [IMAGE]