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

Fix ARG referencing another ARG in FROM statement #1800

Closed
kevinleturc opened this issue Jul 19, 2024 · 2 comments · Fixed by #1801
Closed

Fix ARG referencing another ARG in FROM statement #1800

kevinleturc opened this issue Jul 19, 2024 · 2 comments · Fixed by #1801

Comments

@kevinleturc
Copy link
Contributor

Description

Building from a Dockerfile like the one below:

ARG IMAGE_NAME=alpine
ARG IMAGE_TAG=latest
ARG FULL_IMAGE=${IMAGE_NAME}:${IMAGE_TAG}
FROM ${FULL_IMAGE}

results in the error below:

Caused by: java.lang.IllegalArgumentException: Illegal group reference
    at java.util.regex.Matcher.appendExpandedReplacement (Matcher.java:1113)
    at java.util.regex.Matcher.appendReplacement (Matcher.java:1043)
    at java.util.regex.Matcher.replaceFirst (Matcher.java:1446)
    at java.lang.String.replaceFirst (String.java:3025)
    at io.fabric8.maven.docker.util.DockerFileUtil.resolveImageTagFromArgs (DockerFileUtil.java:189)
    at io.fabric8.maven.docker.util.DockerFileUtil.extractBaseImages (DockerFileUtil.java:70)

This is because DockerFileUtil.resolveImageTagFromArgs doesn't recursively resolve the args, and the curly brackets of the inner arg breaks the Pattern replacement.

Info

  • docker-maven-plugin version: 0.44.0
  • Maven version (mvn -v): 3.9.8
  • Docker version: 27.0.3
@rohanKanojia
Copy link
Member

@kevinleturc : I have released 0.45.0 . Could you please check if everything is working as expected in your project and provide feedback?

@kevinleturc
Copy link
Contributor Author

@kevinleturc : I have released 0.45.0 . Could you please check if everything is working as expected in your project and provide feedback?

I have checked the fix in our project and everything is working as expected.

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

Successfully merging a pull request may close this issue.

2 participants