Pre install python packages for certbot

Hi, I was wondering if it was possible to pre install the python environment and its packages, possibly something like the ‘–os-packages-only’ flag?

I’m using certbot-auto inside a container along side nginx as it seemed more convenient to do that. I have it setup to install all of the OS deps when building the container just not the python packages so they always install whenever the container is started.

Thanks

I don’t know if this is dumb, but could you run certbot-auto --version as a build step in the Dockerfile?

It would bring certbot-auto to a state where it would be usable, including OS dependencies and Python packages.

The one problem I see with that is that if there was a newer version of certbot-auto available at runtime, it would basically wipe out the venv and do it again anyway. For this reason it may be better to use certbot from the distro package repository, because it won’t force you to upgrade at runtime. see advice below

1 Like

Amusingly, I believe my colleague @sydneyli has added precisely the option that you want just a few days ago:

It’s called --install-only.

1 Like

To address @_az’s concern about the newer version available at runtime, you could have the container-making version use --install-only and the runtime version use --no-self-upgrade. Then the container version does upgrade packages, while the runtime version doesn’t. :slight_smile:

1 Like

Great, that looks like what I’ll need. When will this make it into the main certbot auto file at https://dl.eff.org/certbot-auto?

Thanks

I’m not positive, but I would guess within the next 1-2 weeks.

As @_az mentioned, you can also use --version to have the same effect, but that side effect is somewhat counterintuitive and undocumented and it could make your script harder to understand (although you can always add a comment explaining the effect). If you need a solution in the meantime, that’s an available option!

Ok I’ll keep an eye out for that then. I have added the --version flag which works as I need for now and I’ll update when the change comes in :slight_smile:

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.