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

docker: consider each requirement when updating dependencies #3277

Merged
merged 5 commits into from
Mar 23, 2021

Conversation

mctofu
Copy link
Contributor

@mctofu mctofu commented Mar 16, 2021

This change works toward resolving #3173 with an alternate approach to #3251. It maintains grouping of updates so that we can update php:8.0.1-apache and php:8.0.1-cli in a single PR instead of two as suggested in #3251 (review).

Prior to this change if there were multiple tags with different prefixes/suffixes we'd only resolve the latest version for one of them and would end up updating all of the tags to a common version:

=== php (8.0.1-apache)
 => checking for updates 1/1
 => latest available version is 8.0.3-apache
 => latest allowed version is 8.0.3-apache
 => requirements to unlock: own
 => requirements update strategy: 
 => updating php from 8.0.1-apache to 8.0.3-apache

    ± Dockerfile
    ~~~
    1c1
    < FROM php:8.0.1-apache
    ---
    > FROM php:8.0.3-apache
    ~~~

    ± Dockerfile.cli
    ~~~
    1c1
    < FROM php:8.0.1-cli
    ---
    > FROM php:8.0.3-apache
    ~~~

This change resolves the latest version for each tag we can correctly preserve the prefix/suffix in the update:

=== php (8.0.1-apache)
 => checking for updates 1/1
 => latest available version is 8.0.3-apache
 => latest allowed version is 8.0.3-apache
 => requirements to unlock: own
 => requirements update strategy: 
 => updating php from 8.0.1-apache to 8.0.3-apache

    ± Dockerfile
    ~~~
    1c1
    < FROM php:8.0.1-apache
    ---
    > FROM php:8.0.3-apache
    ~~~

    ± Dockerfile.cli
    ~~~
    1c1
    < FROM php:8.0.1-cli
    ---
    > FROM php:8.0.3-cli
    ~~~

One caveat is this only works if the tags are in different files. If a Dockerfile includes two tags with different prefixes/suffixes then we still end up replacing both of them with a single tag. Fixing that requires splitting out to multiple dependencies and updating the file updater to handle multiple dependencies. I started going down that road (b5b80df) but that's going to be a bigger chunk of work and I think it would be better to release this initial fix first.

@mctofu mctofu changed the title [WIP] docker: consider each requirement when updating dependencies docker: consider each requirement when updating dependencies Mar 20, 2021
@mctofu mctofu marked this pull request as ready for review March 20, 2021 00:55
@mctofu mctofu requested a review from a team as a code owner March 20, 2021 00:55
Copy link
Contributor

@feelepxyz feelepxyz left a comment

Choose a reason for hiding this comment

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

Thanks for splitting this out of the file updater WIP, shipping this first makes lots of sense to me 👍

Changes LGTM 💯

@mctofu mctofu merged commit 464e846 into main Mar 23, 2021
@mctofu mctofu deleted the mctofu/docker-tag-handling-updater branch March 23, 2021 21:08
@mctofu mctofu mentioned this pull request Mar 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants