Building workload fails with error resolving dockerfile path: please provide a valid path to a Dockerfile within the build context with --dockerfile
search cancel

Building workload fails with error resolving dockerfile path: please provide a valid path to a Dockerfile within the build context with --dockerfile

book

Article ID: 406518

calendar_today

Updated On:

Products

VMware Tanzu Application Platform

Issue/Introduction

Attempting to build workload fails with error: 

error resolving dockerfile path: please provide a valid path to a Dockerfile within the build context with --dockerfile

The dockerfile path is configured in template as follows:

    - name: dockerfile
      value: ./Dockerfile

Developer is following this guide for Use Dockerfile-based builds with Supply Chain Choreographer: https://techdocs.broadcom.com/us/en/vmware-tanzu/standalone-components/tanzu-application-platform/1-12/tap/scc-dockerfile-based-builds.html

Environment

Tanzu Application Platform 

Cause

Maven can change the directory path to dockerfile during compilation.

Resolution

We must check the dockerbuild path directly in the JAR file downloaded from maven.

Validate the Maven resource in the build log. It should look like: 

build    30-Jul-2025 14:10:19         34 + |    value: https://artifactory.<sample maven>/artifactory/cf-mvn-development-local
build    30-Jul-2025 14:10:19         35 + |  - name: maven
build    30-Jul-2025 14:10:19         36 + |    value:
build    30-Jul-2025 14:10:19         37 + |      artifactId: example-java-app
build    30-Jul-2025 14:10:19         38 + |      groupId: com.example.group
build    30-Jul-2025 14:10:19         39 + |      type: jar
build    30-Jul-2025 14:10:19         40 + |      version: 1.0.0-feature-docker-build

Download the JAR file from the maven and inspect the contents. This can be done by commands.

jar tf example-java-app.jar | grep -i dockerfile

or

unzip -l example-java-app.jar| grep -i dockerfile

Make sure that the dockerfile value points to the correct relative path.

    - name: dockerfile
      value: ./Dockerfile

In one example, the Dockerfile path changed from ./main/src/Dockerfile to ./BOOT-INF/classes/Dockerfile after getting compiled by maven.

Once the dockerfile path is corrected then retry the build of workload.