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

Pass extra index url with build secrets #28430

Closed
wants to merge 2 commits into from

Conversation

gunziptarball
Copy link

Proposed approach to installing packages from a password-protected extra index URL without persisting in a built image. I could use help with building a test for this too (see TODO remarks). I'll try to add one when I have more time, but wanted to pitch the idea first. Thanks! 😄

Also many thanks and props to @potiuk for really cool work on the Dockerfile. I've learned a lot about the new features from this!

References

related: #22492

@boring-cyborg boring-cyborg bot added area:production-image Production image improvements and fixes kind:documentation labels Dec 17, 2022
@boring-cyborg
Copy link

boring-cyborg bot commented Dec 17, 2022

Congratulations on your first Pull Request and welcome to the Apache Airflow community! If you have any issues or are unsure about any anything please check our Contribution Guide (https://github.com/apache/airflow/blob/main/CONTRIBUTING.rst)
Here are some useful points:

  • Pay attention to the quality of your code (flake8, mypy and type annotations). Our pre-commits will help you with that.
  • In case of a new feature add useful documentation (in docstrings or in docs/ directory). Adding a new operator? Check this short guide Consider adding an example DAG that shows how users should use it.
  • Consider using Breeze environment for testing locally, it's a heavy docker but it ships with a working Airflow and a lot of integrations.
  • Be patient and persistent. It might take some time to get a review or get the final approval from Committers.
  • Please follow ASF Code of Conduct for all communication including (but not limited to) comments on Pull Requests, Mailing list and Slack.
  • Be sure to read the Airflow Coding style.
    Apache Airflow is a community-driven project and together we are making it better 🚀.
    In case of doubts contact the developers at:
    Mailing List: dev@airflow.apache.org
    Slack: https://s.apache.org/airflow-slack

@potiuk
Copy link
Member

potiuk commented Jan 11, 2023

Thenks for kudos. Sorry for not responding before.

I tnink however, that this is one is completely not needed. The image is multi-segment one. And pip install is deliberately only done in the "airlfow-build-image" stage. Then installed packages are copied (without requirements or secrets) into the final (main) segment and original "build" segment image is not stored anywhere but locally stored `build-image' state - which you can remove after the build is successful.

The final image has only installed package binaries in /root/.local - no other information is stored. You can check it by using dive command and examining the layers.

Provisionally closing that one unless there is something I do not understand.

# This is a multi-segmented image. It actually contains two images:
#
# airflow-build-image  - there all airflow dependencies can be installed (and
#                        built - for those dependencies that require
#                        build essentials). Airflow is installed there with
#                        --user switch so that all the dependencies are
#                        installed to ${HOME}/.local
#
# main                 - this is the actual production image that is much
#                        smaller because it does not contain all the build
#                        essentials. Instead the ${HOME}/.local folder
#                        is copied from the build-image - this way we have
#                        only result of installation and we do not need
#                        all the build essentials. This makes the image
#                        much smaller.

@potiuk potiuk closed this Jan 11, 2023
@gunziptarball
Copy link
Author

Thanks for the review! I had thought this would be a problem based on this article but I overlooked the bit that said a work around was to use multi stage builds. In this particular case I guess it is indeed unneeded.

@potiuk
Copy link
Member

potiuk commented Jan 12, 2023

Yeah. The buildkit --secret is pretty cool but it does not solve the problem of building things locally. If you want to have remote cache (like we do) and use it extensively during the build then I found it rather useless. Multi-stage builds are much more cache-friendly in this case because when you rebuild the image locally with cache, you can pull most of the layers rather than rebuild them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:production-image Production image improvements and fixes kind:documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants