Skip to content

docker.buildArg.* properties not taken into account in OpenShift plugins #2904

@sunix

Description

@sunix

Describe the bug

The JKube Openshift Maven plugin fails to recognize specified Docker build-arg when they are injected into a Dockerfile from Maven properties. This issue manifests specifically when using Maven properties and does not occur with the XML/Gradle DSL configuration since #2895.
This issue occurs despite the JKube documentation confirming that build arguments can be specified either via the plugin configuration or as Maven properties.

Eclipse JKube version

SNAPSHOT

Component

OpenShift Maven Plugin

Apache Maven version

None

Gradle version

None

Steps to reproduce

  1. Set Up the Dockerfile:
    Place the following content in src/main/docker/Dockerfile:

    ARG FILE_EXTENSION
    FROM docker.io/alpine:latest as builder
    RUN touch test.${FILE_EXTENSION}
    
    FROM docker.io/alpine:latest
    COPY --from=builder /test.txt /test.txt
    
    ENTRYPOINT ["ls"]
  2. Configure the JKube Plugin:
    Insert the JKube Openshift Maven plugin configuration into your pom.xml:

    <plugin>
        <groupId>org.eclipse.jkube</groupId>
        <artifactId>openshift-maven-plugin</artifactId>
        <version>1.17-SNAPSHOT</version>
        <configuration>
          <buildStrategy>docker</buildStrategy>
          <images>
            <image>
              <name>helloworld:%l</name>
              <build>
                <contextDir>${project.basedir}/src/main/docker/</contextDir>
                <dockerFile>Dockerfile</dockerFile>
              </build>
            </image>
          </images>
        </configuration>
    </plugin>
  3. Define the Build Argument:
    Define the build argument for the Docker image in your pom.xml:

    <properties>
        <docker.buildArg.FILE_EXTENSION>txt</docker.buildArg.FILE_EXTENSION>
    </properties>
  4. Execute the Build Command:
    Execute the build using the following Maven command:

    mvn oc:build
    
  5. Error Observation:
    The build process fails, yielding the following output:

    [INFO] oc: --> abd4c9e7124f
    [INFO] oc: [1/2] STEP 3/3: RUN touch test.${FILE_EXTENSION}
    [INFO] oc: --> ee9fcbe057df
    [INFO] oc: [2/2] STEP 1/5: FROM docker.io/alpine
    [INFO] oc: [2/2] STEP 2/5: COPY --from=builder test.txt test.txt
    [ERROR] oc: Failed to execute the build [Unable to build the image using the OpenShift build service]
    [ERROR] oc: Failed to tail build log: %s: java.lang.IllegalStateException: java.io.IOException: channel already closed with exception
    

Expected behavior

The docker.buildArg.FILE_EXTENSION property should be properly processed, enabling the substitution of ${FILE_EXTENSION} in the Dockerfile and ensuring the successful build of the Docker image with the specified configurations.

Runtime

OpenShift

Kubernetes API Server version

1.25.3

Environment

Linux

Eclipse JKube Logs

No response

Sample Reproducer Project

No response

Additional context

No response

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions