-
Notifications
You must be signed in to change notification settings - Fork 157
feat: secure, small, multi-stage Dockerfile #596
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
pfarikrispy
commented
Nov 21, 2025
- separate build into stage
- isolate base image and apt-get
- isolate the app build
- copy only the app into a secure Chainguard Python image that's updated frequently
- group stmnts for less layers
- use image tag SHAs for more (supply chain) security
- make non-root user explicit in final stage
- smaller image that's also more secure
GDay
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! First time hearing about chainguard, looks good. One question before I merge this.
|
Yes you are right. Latest will fetch 3.14, which is the latest and has all
the security fixes. However...
Chainguard gives you almost daily free builds with any new cve resolved.
But you cannot pin the version.
For that you need a license. Using chainguard gives you the most secure
minimal base image for the binary, but you will have to make the code work
with the latest python version. It's a trade off.
I believe Google has a special zero-cve or secure version of python as
well. I'll have to look for it. They've hardened 250 or so essential open
source containers so projects can build more secure images.
…On Wed, Nov 26, 2025, 02:12 Stan Triepels ***@***.***> wrote:
***@***.**** commented on this pull request.
Thanks! First time hearing about chainguard, looks good. One question
before I merge this.
------------------------------
In back/Dockerfile
<#596 (comment)>
:
> RUN pipenv install --system
RUN django-admin compilemessages
-CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor/conf.d/supervisord.conf"]
+# checkov:skip=CKV_DOCKER_7: zero-CVE fresh image every build
+FROM ***@***.***:136aad7020e00a98f617f3d3343cc7601b7823405eb2bc581eae5f5a8c21e8d0
Shouldn't this be 3.13 instead of latest? It looks like latest will
download python 3.14?
—
Reply to this email directly, view it on GitHub
<#596 (review)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AC622W75SH25UCSHKM7RXGD36T47ZAVCNFSM6AAAAACMZNSQTGVHI2DSMVQWIX3LMV43YUDVNRWFEZLROVSXG5CSMV3GSZLXHMZTKMBXG42DONRUHA>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
|
I found Google's distroless containers However, from the thread there asking for other python versions, I was led to nvidia's collection of distroless containers for various version of python and dual arch builds (amd and arm!) |
replace chainguard's latest python container (3.14) with a distroless build from nvidia that uses python 3.13
|
Thank you! This is great, except I get an error when deploying: It looks like they also stripped supervisord from the nvidia image. |
|
Ah yes, I see. I don't fully understand your app nor python. I'm more an engineer than a developer. Sorry. Wanted to make a smaller, more secure container image than the current one. I would like to isolate functionality into their own layers:
then copy the results into a distroless image with python. |
redo layers: - use debian 13 (trixie) to install supervisord - use python 3.13 with trixie to build the app - copy everything into the distroless python image from nvidia
|
@GDay I'm sorry but I'm having troubles redesigning the Dockerfile so that it become a secure multi-stage file because I don't understand Python building enough. I'm expecting a I have tried several iterations of the layers locally but each time pipenv complains with the same error: I'd love to help you get an improved container spec but I need some assistance with Python building. I also tried to just use one layer to build the app and then copy artifacts into the distroless container, but it's not building the app (yet). Do you have any ideas to make that work? |