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

Can't figure out how to set the image tag #1758

Open
davidmichaelkarr opened this issue Feb 23, 2024 · 3 comments
Open

Can't figure out how to set the image tag #1758

davidmichaelkarr opened this issue Feb 23, 2024 · 3 comments

Comments

@davidmichaelkarr
Copy link

davidmichaelkarr commented Feb 23, 2024

We are using io.fabric8:docker-maven-plugin:0.44.0.

We converted from using the (very) old spotify plugin. We're using the plugin in a relatively simple way, and that's all we need, but there's one thing that we're having trouble figuring out, perhaps because of issues in the documentation, but I'm not sure.

Our main issue right now is that we're unable to figure out how to pass the required image tag on the mvn command line. We've tried setting a couple of different properties that were implied by your documentation, but nothing worked. We've at least been able to hardcode the tag in the plugin definition, but that's just temporary.

The following is our current plugin definition, although I know it has a lot of ignored cruft that we have to clear out. I think it's really only the initial block that is relevant.

<plugin>
	<groupId>io.fabric8</groupId>  
	<artifactId>docker-maven-plugin</artifactId>  
	<version>0.44.0</version>
	<configuration>
		<images>     
			<image>       
			<name>${docker.registry}/com.att.idp/${serviceArtifactName}</name>  
			<build>         
				<dockerFileDir>${project.basedir}/src/main/docker</dockerFileDir>         
				<tags>                        
					<tag>dev-latest</tag>
				</tags>  
				<filter>@</filter> 
			</build>     
			</image> 
		</images>  
		<verbose>true</verbose>
		<imageName>${docker.registry}/com.att.idp/${serviceArtifactName}</imageName>
		<dockerDirectory>${project.basedir}/src/main/docker</dockerDirectory>
		<serverId>docker-hub</serverId>
		<registryUrl>https://${docker.registry}</registryUrl>
		<imageTags>
			<imageTag>${project.version}</imageTag>
			<imageTag>dev-latest</imageTag>
		</imageTags>
		<forceTags>true</forceTags>
		<resources>
			<resource>
				<targetPath>/</targetPath>
				<directory>${project.build.directory}</directory>
				<include>${project.build.finalName}.jar</include>
			</resource>
			<resource>
				<targetPath>/</targetPath>
				<directory>${project.build.directory}</directory>
				<include>opt/ajsc/etc/config/*</include>
				<includes>
					<include>**/*</include>
				</includes>
			</resource>
			<resource>
				<targetPath>/</targetPath>
				<directory>${project.build.directory}</directory>
				<include>prometheus-javaagent.jar</include>
			</resource>
		</resources>
	</configuration>
</plugin>

In my build script, I have a line like this:

... mvn -Ddocker.image.tag="${IMAGE_TAG}" -s $MAVEN_SETTINGS -U docker:build

But this had no effect.

@rohanKanojia
Copy link
Member

rohanKanojia commented Feb 23, 2024

@davidmichaelkarr : Do you want tag value to be configurable via property?

Image name can also include tag part:

<name>${docker.registry}/com.att.idp/${serviceArtifactName}:${yourTagName}</name>  

<tags> option that you're using is for additional tag element which you want to add after build

Apart from this, you can also use pre-existing placeholders like %l (latest), %v (project version), %t (timestamp)

@davidmichaelkarr
Copy link
Author

The first option is ideal. We will need to be able to set the property used there on the mvn command line.

@rohanKanojia
Copy link
Member

@davidmichaelkarr : By first option you mean the tag property in image name, right? Is it working if you specify it like this?

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

2 participants