-
Notifications
You must be signed in to change notification settings - Fork 7
Add Dockerfile with minimal supported Python version (3.10) #16
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: main
Are you sure you want to change the base?
Conversation
This is an interesting addition to the repo, however:
Otherwise, we're open to accepting this, thanks for your contribution! |
ca-certificates \ | ||
curl \ | ||
git \ | ||
unzip \ |
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.
ca-certificates
: we shouldn't need to install anymore than what the image includes, unless you're telling me it doesn't have any, then this is acceptable. Have we verified that or is this cargo-culted, is my ask.curl
: doesn't look like we're using cURL anywhere in this Dockerfile, if so, please remove it.git
: all we're using GIt is to download ASDF, for which I'll add comments later.unzip
: same as cURL, we aren't using it so this just bloats the image.
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 for the review,
curl
is used by ASDF to download latest Terraform available version. We can decide to get rid of it or keep it in the image so that the user can eventually update its Terraform versiongit
is used by both the ASDF installation and thestacks
tools as well (hosted on GitHub). Good point, this might be removed afterunzip
is used by ASDF during when installation Terraform version and also by the installation of thestacks
tool (mainly by some Python dependencies, but not sure)
For ca-certificates
, I can't recall, but I think I got TLS warning preventing me to download from GitHub and all Python module dependencies.
For most of them, true, we can decide if we want to keep them or not.
Let me know what you'd prefer.
@@ -0,0 +1,32 @@ | |||
FROM python:3.10-slim |
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.
FROM python:3.10-slim | |
FROM docker.io/python:3.10-slim |
&& apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false \ | ||
&& rm -rf /var/lib/apt/lists/* |
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.
I think rm -rf /var/lib/apt/lists/*
is all you need here, but I might be wrong on this one.
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.
You need to purge all installed dependencies pull from the packages we want, as well as unused packages. This is what the line 11 does.
I might have kept the line 11 because I found out that there was no need to uninstall tools provisioned for installation what we want (stacks
and ASDF).
ARG ASDF_VERSION="v0.16.7" | ||
ENV ASDF_DATA_DIR="/opt/asdf-data" | ||
ENV ASDF_INSTALL_DIR="/opt/asdf" | ||
ENV PATH="${ASDF_DATA_DIR}/shims:${ASDF_INSTALL_DIR}/bin:${PATH}" | ||
|
||
RUN git clone \ | ||
--branch "${ASDF_VERSION}" \ | ||
--depth=1 \ | ||
https://github.com/asdf-vm/asdf.git "${ASDF_INSTALL_DIR}" \ | ||
&& asdf --help | ||
|
||
RUN asdf plugin add tfswitch \ | ||
&& asdf install tfswitch latest \ | ||
&& asdf global tfswitch latest \ | ||
&& tfswitch --latest |
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.
This doesn't belong to Stacks and shouldn't be part of this image.
May I suggest removing this from the Stacks Dockerfile and then building an image FROM stacks
that adds these tools if you need them? Otherwise we're bloating the image with unrelated stuff.
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.
You don't need Terraform for running stacks
?
Indeed, tfswitch
is not needed. It is only a convenient way to get the latest version of Terraform. I can uninstall it, definitely.
&& asdf global tfswitch latest \ | ||
&& tfswitch --latest | ||
|
||
RUN apt-get update \ |
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.
This apt-get update
is unnecessary and defeats the purpose of the rm -rf /var/lib/apt/lists/*
above.
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.
What do you mean ? If there is no cache file in /var/lib/apt/lists/
, you can't run an apt-get install
command if you did not run an apt-get update
before to get updated lists.
&& tfswitch --latest | ||
|
||
RUN apt-get update \ | ||
&& pip install git+https://github.com/tchemineau/cisco-thousandeyes-stacks.git@provides-dockerfile \ |
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.
- Let's switch to
uv
instead ofpip
, it's what we want to primarily support going forward (even though we're keepingpip
compatibility. - This line installs stacks from your own branch on your own fork, we want to use the code in the Docker build context instead so this Dockerfile is not bound to (1) any network services, like GitHub; (2) any specific Git repository; and (3) any specific Git branch.
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. Good point for the URL. Only submitted to get a review first, indeed this should be from master repo.
@@ -9,7 +9,6 @@ dependencies = [ | |||
"cryptography>=43.0.3", | |||
"deepmerge>=2.0", | |||
"gitpython>=3.1.43", | |||
"importlib>=1.0.4", |
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.
Why are we removing importlib
here?
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.
Because the installation of the stacks
tool using pip3
fails otherwise on dependency requirements.
Description
The idea is to provide a minimal
Dockerfile
to build a container image that can runstacks
tool properly.I would like to reuse that mechanism to eventually publish the container image to docker hub, and use it in the CI to do some more advanced testing.
For my use-case, I found out the result container image very useful to quickly run
stacks encrypt
command line.Let me know your thought, and if that could be useful.
Type of Change
Checklist