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

#69 add apt proxy repo support #70

Open
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

Jbaudon
Copy link
Contributor

@Jbaudon Jbaudon commented Nov 13, 2024

Description

Fixes #69

This PR simplifies the installation of Debian packages required by R packages by configuring a Nexus APT proxy repository and updating the related allowlist.
Additionally, it introduces the option to pass certain parameters as environment variables, enabling users to modify the remote source of proxy repositories and specify the APT distribution version. This also allows for the use of private repositories (PyPI, CRAN, or APT) or distributions other than Debian (Ubuntu for instance).

Caveat

I did not implement integration tests because doing so would require modifying the base image to a Debian-based one in integration_tests/Dockerfile. I’m not comfortable making such changes. If you have any suggestions regarding this, I would appreciate your input.

@Jbaudon Jbaudon marked this pull request as ready for review November 19, 2024 13:52
Copy link
Member

@JimMadge JimMadge left a comment

Choose a reason for hiding this comment

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

This looks great, thanks so much 🎉.

I will look to test this soon, but I can't make a guarantee right now.

Regarding integration tests, I think the Bats container image is build on Alpine Linux. There is an apt package in their repos. So it might be possible to add tests after running apk add apt in the container build.

Comment on lines +1 to +6
import os

PYPI_REMOTE_URL = os.getenv("PYPI_REMOTE_URL", "https://pypi.org/")
CRAN_REMOTE_URL = os.getenv("CRAN_REMOTE_URL", "https://cran.r-project.org/")
APT_REMOTE_URL = os.getenv("APT_REMOTE_URL", "http://deb.debian.org/debian")
APT_DISTRO = os.getenv("APT_DISTRO", "bookworm")
Copy link
Member

Choose a reason for hiding this comment

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

This is a good idea, we should add these env vars to the list in the README

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's done.

nexus_api,
name=f"apt-{package}",
description=f"Allow access to {packages} APT package",
expression=f'format == "apt" and path=~"^/pool/.*/{package}.*"',
Copy link
Member

Choose a reason for hiding this comment

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

The regex here feels quite permissive.

What does the directory structure looks like between /pool/ and {package?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Here is an exemple :
https://fr.archive.ubuntu.com/ubuntu/pool/universe/r/r-base/r-base_4.4.2-1_all.deb
Unless you want to restrict access to certain package archives (main, universe, multiverse, restricted for Ubuntu), I don't see how you can make the regex stricter.

Copy link
Member

Choose a reason for hiding this comment

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

I can't remember how flexible the expression language is, but it could be something like ^/pool/(main|universe|multiverse|restricted)/.*/{package}.*" or even ^/pool/({'|'.join(allowed_archives)})/.*/{package}.*".

Copy link
Contributor Author

@Jbaudon Jbaudon Nov 25, 2024

Choose a reason for hiding this comment

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

According the Nexus documentation, the content selector supports Java Regex. It's worth a try.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It does work ! I implemented a new env var for this purpose.

nexus_api,
name="apt-packages",
description="Allow access to 'Packages.gz' file in APT repository",
expression=f'format == "apt" and path=~"^/dists/{APT_DISTRO}/.*/Packages.gz"',
Copy link
Member

Choose a reason for hiding this comment

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

Does this work for all apt repositories? Debian, Ubuntu, Linux Mint for example.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It seems to match for ubuntu https://fr.archive.ubuntu.com/ubuntu/dists/bionic/main/binary-amd64/Packages.gz. I infer it's a standard from apt/debian.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: In review
Development

Successfully merging this pull request may close these issues.

Extend Nexus Allowlist to Support Debian Packages Required for R Package Installation
2 participants