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

fix(dockerfile): Support FROM --arg=$value #12193

Merged
merged 5 commits into from
Oct 20, 2021
Merged

Conversation

anguslees
Copy link
Contributor

Changes:

In multi-platform Dockerfiles using docker buildx, it is common to
use build arg substition such as:

FROM --platform=$BUILDPLATFORM image:tag

This change extends the renovate regex to include $ (actually all
non-whitespace characters) in FROM parameters.

Closes #12122

Documentation (please check one with an [x])

  • I have updated the documentation, or
  • No documentation update is required

How I've tested my work (please tick one)

I have verified these changes via:

  • Code inspection only, or
  • Newly added/modified unit tests, or
  • No unit tests but ran on a real repository, or
  • Both unit tests + ran on a real repository

Fyi, the modified testcase without the patch reproduces the original issue and fails with the following (because it doesn't see the FROM --platform=$arg line at all):

test output
  ● manager/dockerfile/extract › extractPackageFile() › extracts images from all sorts of (maybe multiline) FROM and COPY --from statements

    expect(received).toMatchSnapshot()

    Snapshot name: `manager/dockerfile/extract extractPackageFile() extracts images from all sorts of (maybe multiline) FROM and COPY --from statements 1`

    - Snapshot  - 4
    + Received  + 2

    @@ -17,16 +17,14 @@
          "depType": "stage",
          "replaceString": "image2:1.0.0@sha256:abcdef",
        },
        Object {
          "autoReplaceStringTemplate": "{{depName}}{{#if newValue}}:{{newValue}}{{/if}}{{#if newDigest}}@{{newDigest}}{{/if}}",
    -     "currentDigest": undefined,
    -     "currentValue": undefined,
          "datasource": "docker",
    -     "depName": "image4",
          "depType": "stage",
    -     "replaceString": "image4",
    +     "replaceString": "--platform=$arg",
    +     "skipReason": "contains-variable",
        },
        Object {
          "autoReplaceStringTemplate": "{{depName}}{{#if newValue}}:{{newValue}}{{/if}}{{#if newDigest}}@{{newDigest}}{{/if}}",
          "currentDigest": undefined,
          "currentValue": undefined,

      243 |     it('extracts images from all sorts of (maybe multiline) FROM and COPY --from statements', () => {
      244 |       const res = extractPackageFile(d2).deps;
    > 245 |       expect(res).toMatchSnapshot();
          |                   ^
      246 |       expect(res).toHaveLength(9);
      247 |     });
      248 |     it('handles calico/node', () => {

      at Object.<anonymous> (lib/manager/dockerfile/extract.spec.ts:245:19)

 › 1 snapshot failed.

In multi-platform Dockerfiles using `docker buildx`, it is common to
use build arg substition such as:

```
FROM --platform=$BUILDPLATFORM image:tag
```

This change extends the renovate regex to include `$` (actually all
non-whitespace characters) in FROM parameters.

Fixes renovatebot#12122
@anguslees anguslees changed the title Dockerfile: Support FROM --arg=$value fix: Dockerfile: Support FROM --arg=$value Oct 16, 2021
@anguslees anguslees changed the title fix: Dockerfile: Support FROM --arg=$value fix(manager/dockerfile): Support FROM --arg=$value Oct 16, 2021
viceice
viceice previously approved these changes Oct 16, 2021
@rarkins rarkins changed the title fix(manager/dockerfile): Support FROM --arg=$value fix(dockerfile): Support FROM --arg=$value Oct 20, 2021
@rarkins rarkins enabled auto-merge (squash) October 20, 2021 11:28
@rarkins rarkins merged commit 0e7c50b into renovatebot:main Oct 20, 2021
@renovate-release
Copy link
Collaborator

🎉 This PR is included in version 28.3.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@anguslees anguslees deleted the fromarg branch October 23, 2021 03:43
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 23, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Dockerfile FROM --platform=$arg confuses renovatebot
4 participants