Skip to content
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

Use new python3.10-venv slices when bare in flask-framework extension #606

Merged
merged 21 commits into from
Jun 25, 2024

Conversation

gregory-schiano
Copy link
Contributor

@gregory-schiano gregory-schiano commented Jun 22, 2024

  • Have you signed the CLA?

Using the new python3.11-venv slice to reduce the image of the generated rock when base is bare using flask-framework and django-framework extensions.

How to test:
Install a build of rockcraft using this branch, you need to have docker installed too

git pull https://github.com/canonical/sample-flask.git
cd sample-flask
rockcraft init --profile flask-framework
# Edit the required fields in rockcraft.yaml
# 1. We ensure that when using [email protected] base it still works
rockcraft pack
rockcraft.skopeo copy --insecure-policy oci-archive:sample-flask_0.1_amd64.rock docker-daemon:sample-flask:ubuntu
docker run -d --name flask-ubuntu -p 8000:8000 sample-flask:ubuntu
curl localhost:8000
# Should return <h1>Hello</h1>
docker exec -ti flask-ubuntu bash
/bin/python3 --version
# Should return "Python 3.10.12"
exit
docker stop flask-ubuntu
# Edit rockcraft.yaml, change base to "bare" and add "build-base: [email protected]"
rockcraft clean
rockcraft pack
rockcraft.skopeo copy --insecure-policy oci-archive:sample-flask_0.1_amd64.rock docker-daemon:sample-flask:bare
docker run -d --name flask-bare -p 8000:8000 sample-flask:bare
curl localhost:8000
# Should return <h1>Hello</h1>
docker exec -ti flask-bare bash
/bin/python3 --version
# Should return "Python 3.10.12"
exit
docker stop flask-bare

You can also test using the tutorial (follow the chiseling part of the tutorial):
https://documentation.ubuntu.com/rockcraft/en/latest/tutorials/getting-started-with-flask/

@gregory-schiano gregory-schiano changed the title Use new python3.11-venv slices when bare in flask-framework extension Draft: Use new python3.11-venv slices when bare in flask-framework extension Jun 22, 2024
@jdkandersson
Copy link
Contributor

Why is it Python 3.11.0rc1? The latest version of Python 3.11 is 3.11.9, 0rc1 I think is pre-release so probably doesn't contain a bunch of security fixes etc

Copy link
Collaborator

@cjdcordeiro cjdcordeiro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Btw, the docs (https://documentation.ubuntu.com/rockcraft/en/stable/tutorials/getting-started-with-flask/#chisel-the-rock) should be updated as I'm expecting the resulting rock to now be more than 15% smaller

@gregory-schiano
Copy link
Contributor Author

Btw, the docs (https://documentation.ubuntu.com/rockcraft/en/stable/tutorials/getting-started-with-flask/#chisel-the-rock) should be updated as I'm expecting the resulting rock to now be more than 15% smaller

Indeed, but not that this %age (like the size also provided in this tutorial) might change at any time due to new packages, and dependencies.

@cjdcordeiro
Copy link
Collaborator

cjdcordeiro commented Jun 24, 2024

Btw, the docs (https://documentation.ubuntu.com/rockcraft/en/stable/tutorials/getting-started-with-flask/#chisel-the-rock) should be updated as I'm expecting the resulting rock to now be more than 15% smaller

Indeed, but not that this %age (like the size also provided in this tutorial) might change at any time due to new packages, and dependencies.

It was my impression, from this PR, that if you use a base: bare, the extension will use a slice instead of a deb (which is the case today). Thus, the resulting rock will be smaller.

@github-actions github-actions bot added the documentation Improvements or additions to documentation label Jun 24, 2024
@gregory-schiano
Copy link
Contributor Author

Btw, the docs (https://documentation.ubuntu.com/rockcraft/en/stable/tutorials/getting-started-with-flask/#chisel-the-rock) should be updated as I'm expecting the resulting rock to now be more than 15% smaller

Indeed, but not that this %age (like the size also provided in this tutorial) might change at any time due to new packages, and dependencies.

It was my impression, from this PR, that if you use a base: bare, the extension will use a slice instead of a deb (which is the case today). Thus, the resulting rock will be smaller.

You understood properly, but the size of the images depends on the size of the dependencies installed and the size of the files the slices are setting. This can change overtime.

@cjdcordeiro
Copy link
Collaborator

Btw, the docs (https://documentation.ubuntu.com/rockcraft/en/stable/tutorials/getting-started-with-flask/#chisel-the-rock) should be updated as I'm expecting the resulting rock to now be more than 15% smaller

Indeed, but not that this %age (like the size also provided in this tutorial) might change at any time due to new packages, and dependencies.

It was my impression, from this PR, that if you use a base: bare, the extension will use a slice instead of a deb (which is the case today). Thus, the resulting rock will be smaller.

You understood properly, but the size of the images depends on the size of the dependencies installed and the size of the files the slices are setting. This can change overtime.

Ofc it can, but in that case, we wouldn't be stating any sizes anywhere, and we are (64MB , and then 15% reduction). You do agree that, with your changes, the size reduction will no longer be 15% right? If that's true, then the doc needs fixing

@gregory-schiano
Copy link
Contributor Author

Btw, the docs (https://documentation.ubuntu.com/rockcraft/en/stable/tutorials/getting-started-with-flask/#chisel-the-rock) should be updated as I'm expecting the resulting rock to now be more than 15% smaller

Indeed, but not that this %age (like the size also provided in this tutorial) might change at any time due to new packages, and dependencies.

It was my impression, from this PR, that if you use a base: bare, the extension will use a slice instead of a deb (which is the case today). Thus, the resulting rock will be smaller.

You understood properly, but the size of the images depends on the size of the dependencies installed and the size of the files the slices are setting. This can change overtime.

Ofc it can, but in that case, we wouldn't be stating any sizes anywhere, and we are (64MB , and then 15% reduction). You do agree that, with your changes, the size reduction will no longer be 15% right? If that's true, then the doc needs fixing

Sure agree, that was just a side note.
I've already updated the doc, we went from 65MB to 46MB, so 30% less

@cjdcordeiro
Copy link
Collaborator

Waiting on canonical/chisel-releases#271

Copy link
Collaborator

@cjdcordeiro cjdcordeiro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the spread test needs an easy fix (remove the rockcraft.yaml)

@gregory-schiano gregory-schiano changed the title Draft: Use new python3.11-venv slices when bare in flask-framework extension Draft: Use new python3.10-venv slices when bare in flask-framework extension Jun 25, 2024
@gregory-schiano
Copy link
Contributor Author

For reference, the ubuntu 22.04 base leads to a 65MB image, while the bare base image (with python3.10) leads to a 44MB image size

@gregory-schiano gregory-schiano changed the title Draft: Use new python3.10-venv slices when bare in flask-framework extension Use new python3.10-venv slices when bare in flask-framework extension Jun 25, 2024
@tigarmo
Copy link
Collaborator

tigarmo commented Jun 25, 2024

Thanks a lot! Does anyone else want to look into this before I sync it with main & merge?

@cjdcordeiro
Copy link
Collaborator

@tigarmo please wait for a check on the documentation. Is https://documentation.ubuntu.com/rockcraft/en/stable/reference/extensions/flask-framework/ up to date after this merge?

If the rockcraft.yaml accurate?

@gregory-schiano
Copy link
Contributor Author

@tigarmo please wait for a check on the documentation. Is https://documentation.ubuntu.com/rockcraft/en/stable/reference/extensions/flask-framework/ up to date after this merge?

If the rockcraft.yaml accurate?

I didn't change anything about the user experience. The documentation update needed was about the size reduction of the produced chiseled rock.
I've done a review of the existing documentation to ensure something needs to be updated, and didn't find anything else.
But could be good to have a second pair of eyes

@tigarmo tigarmo merged commit 983a391 into canonical:main Jun 25, 2024
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation priority
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants