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 release - tags used for created images #2373

Closed
pszlazak opened this issue Jul 15, 2021 · 4 comments · Fixed by #2374
Closed

Docker release - tags used for created images #2373

pszlazak opened this issue Jul 15, 2021 · 4 comments · Fixed by #2374
Assignees
Labels
C: packaging Installation and packaging of Black

Comments

@pszlazak
Copy link
Contributor

pszlazak commented Jul 15, 2021

Describe the bug

When you are creating Docker image, you always tag it with latest tag and either:

  • Git tag
    or:
  • latest_non_release

This is done in line # 41 of docker.yml.
Earlier GIT_TAG is prepared in line # 32 of docker.yml.

To Reproduce

Pull both images:

$ docker pull pyfound/black:latest
$ docker pull pyfound/black:latest_non_release

Check version of Black for both images:

$ docker run --rm -it pyfound/black:latest black --version
black, version 0.1.dev1+g91773b8
$ docker run --rm -it pyfound/black:latest_non_release black --version
black, version 0.1.dev1+g91773b8

Of course, there can be a point in time when latest is same as image tagged with Git tag, but every push to main branch will produce new Docker image.

Expected behavior

latest tag should correspond to latest released version of Black. So in my automation I can always pull Docker image related to the newest released version of Black.

Environment (please complete the following information):

N/A

Does this bug also happen on main?

N/A

Additional context

N/A

@cooperlees cooperlees self-assigned this Jul 15, 2021
@JelleZijlstra JelleZijlstra added the C: packaging Installation and packaging of Black label Jul 15, 2021
@cooperlees
Copy link
Collaborator

Hi,

Thanks for the report, but that is not how docker hub works by default and how most projects seem to use default latest tagging with their docker images too. We don’t control the latest tag, it gets auto moved with every upload. Most other docker projects (from what I seen) use latest for every version that gets upload too. I’d prefer we stay the norm for docker (happy to be proven wrong here).

So our tagging today is:

  • Version only
  • Everything else gets latest_non_release
  • Everything gets latest at time of upload

I guess we could introduce a tag (maybe latest_release) to achieve what you want here. If we could update the action to move this tag on a release I’d happily accept that. I might get to trying to add this one day, but I don’t know how to achieve this off the top of my head in the action .yaml config …

@pszlazak
Copy link
Contributor Author

Just confirmed using open source Docker Registry:

  • if you push without tag, latest tag will be added automatically
  • but if you push with any tag, no latest is created

So I can be in the situation where I have:

  • image with tag v1 and latest
  • image with tag v2 (of course with some changes)

Then I can retag them, so latest is used for v2.

I guess the problem is with following line of docker.yml:

tags: pyfound/black:latest,pyfound/black:${{ env.GIT_TAG }}
      ^^^^^^^^^^^^^^^^^^^^

Maybe you should have two separate steps:

      - name: Build and push
        uses: docker/build-push-action@v2
        with:
          context: .
          platforms: linux/amd64,linux/arm64
          push: true
          tags: pyfound/black:${{ env.GIT_TAG }}
      - name: Build and push latest tag
        if: ${{ github.event_name == 'release' && github.event.action == 'created' }}
        uses: docker/build-push-action@v2
        with:
          context: .
          platforms: linux/amd64,linux/arm64
          push: true
          tags: pyfound/black:latest

Please check following documentation:

Although I have no place to check if it works.

@cooperlees
Copy link
Collaborator

I am all for doing this, but I don't like using latest for this use case. It goes against what most people expect latest to be. I'd accept (or when I get around to it) latest_release tag for this usage. I'd like to leave latest to be exactly that, the latest built image.

For testing this: You can fork black and push to your own username/black repository (by editing the action yaml) on docker hub if you add a secret to your forked repo. That's how I've tested before or I just use a personal project and test it there then copy it to a PR here.

pszlazak added a commit to pszlazak/black that referenced this issue Jul 16, 2021
Docker images created during release process will have extra tag 'latest_release'.

This closes psf#2373.
@pszlazak
Copy link
Contributor Author

OK, tested. Pull request is created -> #2374.

cooperlees pushed a commit that referenced this issue Jul 16, 2021
Docker images created during release process will have extra tag 'latest_release'.

This closes #2373.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C: packaging Installation and packaging of Black
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants