quarkusio / quarkus

Quarkus: Supersonic Subatomic Java.
https://quarkus.io
Apache License 2.0
13.77k stars 2.68k forks source link

quarkus.container-image.image ignores tag #12651

Open zeljkot opened 4 years ago

zeljkot commented 4 years ago

Describe the bug

12070 introduces quarkus.container-image.image property, which contains registry and image name for GitLab compatibility. However, it overrides whatever is stored in quarkus.container-image.tag property and adds the latest tag. It does respect additional-tags.

Note that JIB's and GitLab's definition of an image is different: JIB's contains a version while GitLab's does not. GitLab's CI_REGISTRY_IMAGE, the version is not contained as it does not know which version is being built.

Workaround: add version to additional-tags:

quarkus:
  container-image:
    tag: i-am-ignored
    additional-tags:
      - integration-test
      - ${quarkus.application.version}

Expected behavior The content of tag should be used as a default tag.

Actual behavior The image is tagged with the latest and additional-tags, while it should be tagged with x.y.z-SNAPSHOT and additional-tags. The content of tag is ignored.

To Reproduce

Link to a small reproducer (preferably a Maven project if the issue is not Gradle-specific).

Or attach an archive containing the reproducer to the issue.

Steps to reproduce the behavior:

quarkus:
  container-image:
    additional-tags: integration-test

In build a script, set

export QUARKUS_CONTAINER_IMAGE_IMAGE=${CI_REGISTRY_IMAGE}

Configuration

# Add your application.properties here, if applicable.

Screenshots (If applicable, add screenshots to help explain your problem.)

Environment (please complete the following information):

Additional context (Add any other context about the problem here.)

geoand commented 4 years ago

Thanks for opening this.

I am not exactly sure whether this should be classified as a bug or not TBH...

@Ladicek @iocanel what do you guys think about this one?

Ladicek commented 4 years ago

@zeljkot If you know that CI_REGISTRY_IMAGE never contains a tag, could you perhaps set quarkus.container-image.image to ${CI_REGISTRY_IMAGE}:${quarkus.application.version:latest}? (See https://quarkus.io/guides/container-image#container-image-options for the default value of quarkus.container-image.tag.)

@geoand / @iocanel: I don't know all the details, but we assume that quarkus.container-image.image contains the full image name, right? In which case, if the tag is missing, we assume latest, because that's the default value. That sounds right to me.

But if quarkus.container-image.image is set, what happens when the other properties (registry, group, name, tag) are set? I kinda have a feeling that this is undefined. Could it be defined in a sensible way? Or could we / should we fail?

geoand commented 4 years ago

@geoand / @iocanel: I don't know all the details, but we assume that quarkus.container-image.image contains the full image name, right? In which case, if the tag is missing, we assume latest, because that's the default value. That sounds right to me.

Yes, thats is exactly what we do.

But if quarkus.container-image.image is set, what happens when the other properties (registry, group, name, tag) are set? I kinda have a feeling that this is undefined. Could it be defined in a sensible way? Or could we / should we fail?

I think we log a warning that they are ignored

zeljkot commented 4 years ago

Here is the workaround for GitLab:

 $ VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)
 $ export QUARKUS_CONTAINER_IMAGE_IMAGE=${CI_REGISTRY_IMAGE}:${VERSION}
thanhlai1212 commented 2 years ago

https://quarkus.io/guides/container-image#quarkus-container-image_quarkus.container-image.image Represents the entire image string. If set, then group, name, registry, tags, additionalTags are ignored

Example: quarkus.container-image.image=${IMAGE_NAME}:${CI_COMMIT_TAG}

We have 2 options:

  1. "quarkus.container-image.image" OR
  2. "quarkus.container-image.name and quarkus.container-image.tag"