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

tag is needed when pushing to registry #362

Closed
balazssoltesz opened this issue Oct 29, 2021 · 5 comments
Closed

tag is needed when pushing to registry #362

balazssoltesz opened this issue Oct 29, 2021 · 5 comments

Comments

@balazssoltesz
Copy link

balazssoltesz commented Oct 29, 2021

hello, i installed @nx-tools/nx-docker & @nx-tools/docker-metadata packages.
i have a target with the following configuration:

        "docker": {
          "executor": "@nx-tools/nx-docker:build",
          "options": {
            "file": "apps/admin/Dockerfile",
            "push": true,
            "metadata": {
              "images": ["#########"],
              "tags": [
                  "type=match,pattern=admin@(.*),group=1"
              ] 
            }
          },
          "dependsOn": [
            {
              "target": "build",
              "projects": "self"
            }
          ]
        },

Then i added tag "admin@0.1.0" to my last commit, but when i try to run this target, i get the error message: tag is needed when pushing to registry,

Am i doing somthing wrong?

@gperdomor
Copy link
Owner

gperdomor commented Nov 26, 2021

Hi @balazssoltesz, the config seems to be fine... Are you running the builder in your local machine or in a supported CI environment

Even when you running in a local machine and you have a tag, the local context use git symbolic-ref HEAD so will be executed using the branch name, not the admin@0.1.0 tag

@DaSchTour
Copy link
Contributor

DaSchTour commented Jan 23, 2022

I have a similar issue. My setup was working with version 1.1.0-alpha.3 but is now broken with version 2.2.0.

My config with version 1.1.0-alpha.3 is

"executor": "@nx-tools/nx-docker:build",
  "options": {
    "push": true,
    "file": "apps/…/Dockerfile",
    "meta": {
      "enabled": true,
      "images": ["…"]
    }
  }

For version 2.2.0 tried

"executor": "@nx-tools/nx-docker:build",
  "options": {
    "push": true,
    "file": "apps/…/Dockerfile",
    "meta": {
      "enabled": true,
      "tags": ["type=ref,event=branch"],
      "images": ["…"]
    }
  }

I thought this would be equivalent, why does version 2 need more configuration? Everything worked fine in version 1.1.0-alpha.3. With Version 1.0.5 I get the same error. So there is something in that alpha, that makes with work perfectly that is gone in version 2.2.0.

@gperdomor
Copy link
Owner

@DaSchTour for v2 should be:

"executor": "@nx-tools/nx-docker:build",
  "options": {
    "push": true,
    "file": "apps/…/Dockerfile",
    "metadata": {
      "tags": ["type=ref,event=branch"],
      "images": ["…"]
  }
}

metarenamed to metadata... and remove meta.enabled prop

If still having issues please provide a minimum reproduction repository

@DaSchTour
Copy link
Contributor

I updated my configuration to this

"docker": {
      "executor": "@nx-tools/nx-docker:build",
      "options": {
        "push": true,
        "file": "apps/…/Dockerfile",
        "metadata": {
          "tags": [
            "type=schedule",
            "type=ref,event=branch",
            "type=ref,event=tag",
            "type=ref,event=pr",
            "type=semver,pattern={{version}}",
            "type=semver,pattern={{major}}.{{minor}}",
            "type=semver,pattern={{major}}",
            "type=sha,prefix=sha-"
          ],
          "images": […]
        }
      }
    },

My CI fails with

error: tag is needed when pushing to registry
buildx failed with: error: tag is needed when pushing to registry

@DaSchTour
Copy link
Contributor

I had to fix my package-lock and now it actually works. Thanks for the help @gperdomor

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

No branches or pull requests

3 participants