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

bake --print show wrong docker-bake.json #856

Closed
eitsupi opened this issue Nov 22, 2021 · 0 comments · Fixed by #857
Closed

bake --print show wrong docker-bake.json #856

eitsupi opened this issue Nov 22, 2021 · 0 comments · Fixed by #857
Labels
area/bake kind/bug Something isn't working
Milestone

Comments

@eitsupi
Copy link
Contributor

eitsupi commented Nov 22, 2021

The function to display groups added in #720 does not seem to be working correctly.

The json shown in the following example will not work properly and an error will be displayed.

```console
$ docker buildx bake "git://github.com/docker/cli#master" --print
#1 [internal] load git source git://github.com/docker/cli#master
#1 0.686 2776a6d694f988c0c1df61cad4bfac0f54e481c8 refs/heads/master
#1 CACHED
{
"group": {
"default": [
"binary"
]
},
"target": {
"binary": {
"context": "git://github.com/docker/cli#master",
"dockerfile": "Dockerfile",
"args": {
"BASE_VARIANT": "alpine",
"GO_STRIP": "",
"VERSION": ""
},
"target": "binary",
"platforms": [
"local"
],
"output": [
"build"
]
}
}
}
```

{
  "group": {
    "default": [
      "binary"
    ]
  },
  "target": {
    "binary": {
      "context": "git://github.com/docker/cli#master",
      "dockerfile": "Dockerfile",
      "args": {
        "BASE_VARIANT": "alpine",
        "GO_STRIP": "",
        "VERSION": ""
      },
      "target": "binary",
      "platforms": [
        "local"
      ],
      "output": [
        "build"
      ]
    }
  }
}
$ docker buildx bake -f docker-bake.json --print
[+] Building 0.0s (0/0)
docker-bake.json:4
--------------------
   2 |       "group": {
   3 |         "default": [
   4 | >>>       "binary"
   5 |         ]
   6 |       },
--------------------
error: docker-bake.json:4,7-15: Incorrect JSON value type; Either a JSON object or JSON array of objects is required here, to define arguments and child blocks., and 2 other diagnostic(s)

Isn't the correct answer as follows?

{
  "group": {
    "default": [
      {
        "targets": [
          "binary"
        ]
      }
    ]
  },
  "target": {
    "binary": {
      "context": "git://github.com/docker/cli#master",
      "dockerfile": "Dockerfile",
      "args": {
        "BASE_VARIANT": "alpine",
        "GO_STRIP": "",
        "VERSION": ""
      },
      "target": "binary",
      "platforms": [
        "local"
      ],
      "output": [
        "build"
      ]
    }
  }
}

Also, the contents of groups displayed when groups is specified seems to be wrong.
If we specify the above json and let it bake --print again, we will see the json with the default targets as default as shown below.

{
  "group": {
    "default": [
      "default"
    ]
  },
  "target": {
    "binary": {
      "context": "git://github.com/docker/cli#master",
      "dockerfile": "Dockerfile",
      "args": {
        "BASE_VARIANT": "alpine",
        "GO_STRIP": "",
        "VERSION": ""
      },
      "target": "binary",
      "platforms": [
        "local"
      ],
      "output": [
        "build"
      ]
    }
  }
}

My local environment is not yet buildx 0.7.0, so I haven't checked it at hand, but I found this behavior on GitHubActions runner.
https://github.com/rocker-org/rocker-versioned2/runs/4277390774?check_suite_focus=true#step:3:5813
(CI to check if docker-bake.json is in the correct format by executing the bake --print command)

@crazy-max crazy-max added area/bake kind/bug Something isn't working labels Nov 22, 2021
@tonistiigi tonistiigi added this to the v0.7.0 milestone Nov 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/bake kind/bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants